Start Activity of Main project from my library project

后端 未结 2 562
长发绾君心
长发绾君心 2021-01-15 15:41

I have 2 projects. One is my Main Project(A) , and another is a Library Project(B). I want to start an activity which is present in A from an activity which is located in B.

2条回答
  •  无人及你
    2021-01-15 16:15

    You shouldn't need to use an intent filter. The code in Activity A can use

    ComponentName cn = new ComponentName(this, "my.package.MyActivity.B");
    Intent intent = new Intent().setComponent(cn);
    
    startActivity(this, intent);
    

    to specify the activity B should be started.

提交回复
热议问题