0

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 package(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?

GraphicsMuncher
  • 4,583
  • 4
  • 35
  • 50
manju
  • 847
  • 3
  • 16
  • 43

2 Answers2

6

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.

Community
  • 1
  • 1
Mathias Conradt
  • 28,420
  • 21
  • 138
  • 192
  • hi thanks a lot its working awesome...i have some research using this i may need your help in future so plz feel free to respond i may be back... – manju Dec 03 '10 at 10:57
  • hi i think i need more space to explain my scenario so plz look at my answer for further details.. – manju Dec 03 '10 at 11:13
  • in simple ....i have created a button in my app called images,when clicked it should launch the google with images displayed...it is not only applicable for google this idea should be applicable to any installed third party apps.... – manju Dec 03 '10 at 11:28
  • hey its not working for me :( do i need to add something to the manifest file ? – Charan Pai Oct 01 '12 at 09:11
  • @Chinnu Check the log (adb logcat), any error in there? Which component/intent are you trying to call? Maybe it's incorrect / spelling / etc. – Mathias Conradt Oct 01 '12 at 09:42
0

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..

manju
  • 847
  • 3
  • 16
  • 43
  • Hey Manju. . . Have u finished the Activity which you are calling ?? May be it Solve tour Problem. . . –  Apr 29 '11 at 04:48