Start Activity of Main project from my library project

后端 未结 2 560
长发绾君心
长发绾君心 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:35

    You can add custom Action in intent-filter of you activity and start that activity by specifying action

    
        
            
            
            
        
    
    

    start activity with this code:

    final Intent intent = new Intent("my.package.action.MY_ACTION");
    intent.addCategory(getActivity().getPackageName());
    startActivity(getActivity(), intent);
    

提交回复
热议问题