Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Open an external app and then call an intent URI

I have an app 'A'. I am opening another app 'B''s video player and playing a video using an intent URI call like so

    String intentURI = "B://this/123";
    try {
        intent = Intent.parseUri(intentURI, Intent.URI_INTENT_SCHEME);
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        Logger.appendInfoLog("Something went wrong with B", TAG);
        e.printStackTrace();
        Logger.appendErrorLog(e.getMessage(), TAG);
        finish();
    }

startActivity(intent);

Now the necessary condition is for that app 'B' to be open in the background for this to work.If the app is closed(killed by Android or manually) or it has crashed,this throws an error.

Is there a way to open that app 'B' first or check its running status and then make the intent URI call. I will not get control back from that app and once I go to the other app I dont have any control on it until the user presses the back button to return to my app.

UPDATE:

I want to start app 'B' first and then call the intent programmatically. Is this possible

UPDATE

I Ran the Catlog app to check what message comes up in app B. It just shows file 123.file (The one i am trying to play in the app B's video player) not found, but when the app is running in the background it goes through fine. It also shows a warning

java.lang.NullPointerException: PrintLn needs a message

and then it says

Activity displayed, but mediaplayer.is not playingVideo

Also the other app is written in flash and packaged as a native app on adobe air

like image 830
Vrashabh Irde Avatar asked Dec 15 '22 10:12

Vrashabh Irde


2 Answers

I have an app 'A'. I am opening another app 'B''s video player and playing a video using an intent URI call like so

No, you are not. You can tell that by reading the code -- there is no startActivity() call in that code block.

Now the necessary condition is for that app 'B' to be open in the background for this to work.If the app is closed(killed by Android or manually) or it has crashed,this throws an error.

Then apparently app B has a bug. Please contact the author of app B for assistance.

like image 177
CommonsWare Avatar answered Jan 09 '23 17:01

CommonsWare


You can get a list of running apps easily.

ActivityManager manager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
List<RunningAppProcessInfo> processes = manager.getRunningAppProcesses();

And you can launch apps just as easily.

Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage("com.package....");
startActivity(LaunchIntent);

You can't, however, launch an app into background, so this might not solve your issue.

like image 30
unexpectedvalue Avatar answered Jan 09 '23 17:01

unexpectedvalue