[mono-android] ActivityAttribute -> Name Property Bug?
Jonathan Pryor
jpryor at novell.com
Tue Mar 8 12:32:23 EST 2011
On Mar 8, 2011, at 11:17 AM, Travis Smith wrote:
> 2. change activity1.cs, activity attribute to include Name = "Main"
> [Activity (Label = "My Activity", MainLauncher = true, Name = "Main")]
Don't do that. :-)
As per the docs [0]:
This value cannot follow the Android "shortcut" of using . as the first character; it must be a fully-qualified type name.
What could be better specified is that there _must_ be a package name in there, i.e. there must be at least one '.' in there, and you have none. Instead, do:
[Activity (/*...*/,
Name="mypackage.Main")]
public class MainActivity : Activity {...}
HOWEVER...why do you want to do that?
The SOLE reason for using ActivytAttribute.Name is if you want to maintain "backward compatibility" with an existing Java type name, AND the existing type name doesn't match the current namespace+Type name for the type. 99.999% of the time, you SHOULD NOT CARE, and thus, you SHOULD NOT USE the ActivityAttribute.Name property.
(Furthermore, use of *Attribute.Name slows down type lookups at runtime, involves an extra exception catch, and in general should be avoided unless you really, really, need it.)
- Jon
[0] http://docs.monodroid.net/index.aspx?link=P:Android.App.ActivityAttribute.Name
More information about the Monodroid
mailing list