0

It is possible to open up App B from my APP A. Like an PDF from my app in PDF Reader from Adobe Systems.

But I need to come back from PDF Reader as soon User saves the PDF or has completed his work (editing, comment etc.) on the PDF.

Would this be possible, if I do not have any control on APP B?

Johnny2012
  • 1,512
  • 8
  • 31
  • 46

2 Answers2

0

I do not know if some direct method exists, but if not, you could follow this method:

Refer to my answer here: Android how to know an app has been started and range apps priority according the starting times

So you will need to know the package name of the app you are launching to view the PDF (or any app for that matter), which you would obviously know because you are launching it through an intent I suppose.

Just before launching the app B, start an Asynctask() or any background thread where you check whether app B exists in the foreground, using my answer in that question. When you close app B (when your work is completed) ,it will no longer exist in foreground, so then check if app A then exists in the foreground, using the same method.

If it does, well and good. Else, use an intent to launch app A, so that the functionality of what you want is achieved.

Community
  • 1
  • 1
SoulRayder
  • 5,072
  • 6
  • 47
  • 93
0

It is posible to get back the control from another app to your app.

You need to use startActivityForResult to start the other app and override the method onActivityResult to which the control will be returned.

For example your are opening default camera app. you dont have any control over it. Start that app using startActivityForResult,

final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile("URI"));
        startActivityForResult(intent,Reqcode);

After closing the app, the control will return to the following method. The result code in the parameter, will tell you whether the user operation is successful or not.

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {

        //your code here
}
Priya
  • 489
  • 1
  • 10
  • 20