androidkotlinandroid-intentandroid-module

Is there a way from one Phone/Tablet module start Activity to another module activity within the same app without creating a new app in Android?


  val intent = Intent(Intent.ACTION_MAIN)
        .addCategory(Intent.CATEGORY_HOME)
        .setClassName( "com.example.AnotherPhoneTabletModule","com.example.AnotherPhoneTabletModule.MainActivity")
        .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        .addFlags(Intent.FLAG_FROM_BACKGROUND)
        .setComponent(ComponentName("com.example.AnotherPhoneTabletModule", "com.example.AnotherPhoneTabletModule.MainActivity"))

    applicationContext.startActivity(intent)[1]

There are two phone/tablet modules and want to do start activity in another module. However, from the reason of setting flag or category the other module is creating different application. Is it possible in same application to start another activity from another phone/tablet module without using android library module.

Two different apps


Solution

  • val intent = Intent(Intent.ACTION_MAIN)
                .addCategory(Intent.CATEGORY_HOME).setClassName("com.example.AnotherPhoneTabletModule","com.example.AnotherPhoneTabletModule.MainActivity")
                .setComponent(ComponentName("com.example.AnotherPhoneTabletModule", "com.example.AnotherPhoneTabletModule.MainActivity"))
    
            startActivity(intent)
    

    This code worked for me.