I try with this ways but did not get correct way to do this.I am using this code to open another app.
Now i want to know when ever i close or open my second app then i want to get some result of closing second app or opening second app in to my first app.Can it is possible or not if it is possible to get any responce of opening second app or closing second app.
Intent intentt = new Intent(Intent.ACTION_MAIN);
intentt.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intentt.setComponent(new ComponentName("com.example.abc","com.example.abc.MainActivity"));
startActivity(intentt);
This code open my second app after press back button my second app will close at the time of close and opening second app i want to get some result at the time of second app opening or closing some result,i also follow these links also.
I also follow this link to explore or find solution
how i can do this...Thanks in Advance.
with this code my second app is open but after closing second app how do i find or handle callback of second app.
Try With this code for opening one application to another application
From your
FirstApp
call theSecondApp
usingstartActivityForResult()
methodFor example:
When user press back button it will notify in onActivityResult method of FirstApp.
Pass data with Intent and then finish that activity in Second App.Put whatever your data is with
putExtra
. Write this in Second App:Write following code for the in FirstApp. To access the result passed from Second App
For more Detail check this link:
Try this code for checking whether app is running or not:
If the 2nd App is under your control then you can do by
startActivityForResult
:In your
SecondActivity
set the data which you want to return back toFirstActivity
. If you don't want to return back, don't set any.For example: In secondActivity if you want to send back data:
If you don't want to return data:
Now in your FirstActivity class write following code for the
onActivityResult()
method.You Should use startActivityForResult() method to open or close second app because here we pass the intent and request code as parameter which helps to get response in onActivityResult() method.