如何知道/配置Xamarin Android生成的包名?

时间:2016-05-25 13:24:18

标签: android xamarin android-widget xamarin.android android-appwidget

我需要为Widget配置活动指定完整的类名(包括包名),如下所示:

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

但是当我编译我的应用程序并查看生成的清单文件时,我发现活动的名称已更改为md52e27f5924a30b693e8c2cbed2aefe779.MyConfigActivity

如何获取此生成的名称或将其设置为某个位置以便可预测,我可以在appwidget-provider Xml配置文件中使用它?

1 个答案:

答案 0 :(得分:2)

如果您未通过Attribute

指定类别ID,Xamarin会自动生成类ID

一些例子:

活动命名:

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

自动生成清单:

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

BroadcastReceiver命名:

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

自动生成清单:

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