I have an android application that starts pandora by voice command. It works great, but I want the activity to switch back to my application, leaving pandora running in the background. I'm using this code to launch pandora:
PackageManager pm = getPackageManager()
try{
String packageName = "com.pandora.android";
launchIntent = pm.getLaunchIntentForPackage(packageName);
startActivity(launchIntent);
}
catch (Exception e1)
{}
Any thoughts?
First glance I thought you could use
Activity.startActivities, as in:But Pandora needs a little time to start playback and in that case, I think you best bet is to set up a
NotificationListenerServiceand wait for Pandora's notification to be posted, which would indicate playback has started, then launch your app.Here's an example:
In your AndroidManifest
Also, your users will need to enable your app to listen for notifications to be posted under:
But you can direct your users straight there by using the following
Intent: