Start Intent for activity-alias

前端 未结 1 1264
独厮守ぢ
独厮守ぢ 2021-01-13 06:57

I set up some Alias for an activity with different meta-data.

In this meta-data I set the name of the fragment which I then load by reflection.
I don\'t know if

相关标签:
1条回答
  • 2021-01-13 07:50

    To specify the alias, you need to use setComponent(ComponentName) on an empty Intent() object.

    I tend to set the manifest entry to be a relative name

    <activity-alias
        android:name=".ActivityListItem"
    

    (note the period at the beginning of the name), and then form the ComponentName for the Intent using

    Intent intent = new Intent();
    String packageName = context.getPackageName();
    ComponentName componentName = new ComponentName(packageName,
                                                    packageName + ".ActivityListItem");
    intent.setComponent(componentName);
    
    0 讨论(0)
提交回复
热议问题