Calling an action that resides in another package (Android)

I want to call an action that is in another package.

Say, for example, I have Activity (activity1) in my package (package1), and I need to call another Activity (activity2) in another package (package2) from my activity1.

I tried to import package2 into my package1, but it didn’t work ... Can someone please answer me and provide some sample code?

0
source share
2 answers

see Android: launching activity for another third-party application

 final Intent intentDeviceTest = new Intent("android.intent.action.MAIN"); intentDeviceTest.setComponent(new ComponentName("fm.last.android","fm.last.android.LastFm")); startActivity(intentDeviceTest); 

where you can change the intent of VIEW depending on your case.

+6
source

here is my complicated scenario.

step 1; I opened google.com from a web browser on my emulator and opened some images in it, and I pressed the home key and opened my application in which I wrote the code to get the highest activity name and the package of the current task, I mean, that I received information about browser activity ... step 2; from this information, I started the browser from my activity. The old browser starts where it remains the same (showing some images), but when I press the back key on my emulator, it doesn’t fit my application, it returns google.com, and then if I press the back button, it fits my application .... and again, if I run the browser application from my code, it runs on the google main page .. I want to run it in the image section as I need.

0
source

Source: https://habr.com/ru/post/1333670/


All Articles