How to start an activity in an android Application from the Library

后端 未结 4 566
眼角桃花
眼角桃花 2021-02-11 07:24

I have an Android application in Android Studio. And I\'ve added a library into the application. The button, view, and activities are defined in the library. When I click on the

4条回答
  •  既然无缘
    2021-02-11 08:12

    In this case, Intent can be used by providing the full class name including the package.

    Let us suppose your current Activity class is MainActivity.java with package name com.app.myproject.

    And you want to navigate to another Activity with class named Activity.java that is in another package com.app.external.

    Include com.app.external.Activity.java in the manifest of your current project/library.

     
     
    

    And your Intent should be like this -

    Intent intent = new Intent(MainActivity.this, com.app.external.Activity.class);
    
    startActivity(intent);
    

提交回复
热议问题