为什么xamarin将哈希作为命名空间附加?

时间:2015-11-24 15:13:23

标签: xamarin.android

对我的apk运行aapt,我看到有些东西在我的活动名称前面附加了一个哈希,我通常希望看到我的命名空间。这是aapt输出...

C:\Program Files (x86)\Android\android-sdk\build-tools\23.0.1>aapt dump badging c:\base.apk
package: name='fr.company.DematAEAT_Android' versionCode='1' versionName='1.0' platformBuildVersionName='4.0.4-1406430'
install-location:'auto'
sdkVersion:'11'
uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.READ_EXTERNAL_STORAGE'
application-label:'DematAEAT_Android'
application-icon-160:'res/drawable/icon.png'
application: label='DematAEAT_Android' icon='res/drawable/icon.png'
application-debuggable
launchable-activity: name='md5abda05033ab0415fc7a776c5d9734c74.MainActivity'  label='DematAEAT_Android' icon='res/drawable/icon.png'
feature-group: label=''
  uses-feature: name='android.hardware.touchscreen'
  uses-implied-feature: name='android.hardware.touchscreen' reason='default feature for all apps'
main
other-activities
other-receivers
supports-screens: 'small' 'normal' 'large' 'xlarge'
supports-any-density: 'true'
locales: '--_--'
densities: '160'
native-code: 'arm64-v8a' 'armeabi' 'armeabi-v7a' 'x86' 'x86_64'

问题在于启动“可启动活动”。如果我的活动被隐藏在一个带有长期构成的命名空间中,并且我期望经常更改命名空间,我怎样才能创建指向我的活动的意图?

1 个答案:

答案 0 :(得分:1)

这是最新的Xamarin.Android版本中添加的内容,也在更新日志中宣布,以防止我猜的名字冲突。

您可以使用RegiterAttribute或强制ActivityAttribute中的名称来规避这一点:

[Register("myNamespace.ActivityName")]
[Activity()]
public class MyActivity : Activity {...}

[Activity(Name = "myNamespace.ActivityName")]
public class MyActivity : Activity {...}