How to know/configure Xamarin Android generated pa

2019-02-28 19:15发布

问题:

I am required to specify full class name (including package name) for the Widget configuration activity like so:

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:configure="my.package.MyConfigActivity"
    ...
>
</appwidget-provider>

But when I compile my app and look in the generated manifest file, I see that the name of the activity is changed to md52e27f5924a30b693e8c2cbed2aefe779.MyConfigActivity.

How do i get this generated name or set it somewhere so its predictable and I can use it in my appwidget-provider Xml config file?

回答1:

Xamarin auto-generates class ids if you do not specify one via an Attribute

Some examples:

Activity Naming:

[Activity(Label = "ActivityNaming", Name = "com.sushihangover.playscript.MyBigBadGame", MainLauncher = true, Icon = "@mipmap/icon")]
public class MainActivity : Activity
{
  ~~~
}

Auto-generates into the Manifest:

<activity android:icon="@mipmap/icon" android:label="ActivityNaming" android:name="com.sushihangover.playscript.MyBigBadGame">
  <intent-filter>
      ~~~~~
  </intent-filter>
</activity>

BroadcastReceiver Naming:

[BroadcastReceiver(Name = "com.sushihangover.greatapp.MyReceiver")]
public class MyBroadCastReceiver : BroadcastReceiver
{
    public override void OnReceive(Context context, Intent intent)
    {
       ~~~~
    }
}

Auto-generates into the Manifest:

<receiver android:name="com.sushihangover.greatapp.MyReceiver" />