开发者

calling an activity that is in another package(android)

开发者 https://www.devze.com 2023-01-28 12:34 出处:网络
I want to call an activity that is in another package.... Say for example I have an Activity(activity1) in my package(package1) and I need to callanother Activity(activity2) in another packa开发者_运

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

Say for example I have an Activity(activity1) in my package(package1) and I need to call another Activity(activity2) in another packa开发者_运维知识库ge(package2) from my activity1..

I have tried to import the package2 in my package1 but it did not work... Can anyone answer me and provide some sample code?


see Android: Starting An Activity For A Different Third Party App

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 to VIEW depending on your case.


here is my challenging scenario..

step 1; i have opened google.com from web browser on my emulator and opened some images in that and i pressed home key and opened my app in that i have written code for getting the top activity name and package of currently running task, i mean i got browser's top activity information... step 2; from that information i have lunched the browser from my activity..fine browser is launched where it was left previous(showing some images) but when i press the back key on my emulator it is not coming to my app instead it is going back to google.com home page and later if i press back key it is coming to my app....and again if i launch the browser app from my code it is launching in google home page..i want to launch it in image section as i need..

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号