Call emergency application

How can I call an external application from my application?

For example: I need to call Shazam(application) from my application. I see the application package name in logcat.

Will it be useful for any purpose?

+3
source share
3 answers

You can invoke the action of a third-party application as follows.

final Intent shazamIntent = new Intent("com.shazam.android");                
shazamIntent .setComponent(new  ComponentName("com.shazam.android","com.shazam.android.Splash"));
startActivity(shazamIntent );

But this is not the best way. If you change the name of the package (which is a very remote feature) or change the name of the activity (it Splashmay change to something else), your application will break. If Shazam has an intention that you can invoke to start listening to the use of the song (not sure what they have).

, Shazam , .

+1

startActivity.

+1

In particular, the following code works for Shazam:

Intent intent = new Intent("com.shazam.android.intent.actions.START_TAGGING");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

if(!context.getPackageManager().queryIntentActivities(intent, 0).isEmpty()) {
    context.startActivity(intent);
} else {
    // Shazam is not installed
}

START_TAGGING - This is the intention that is issued when you click the Shazam widget.

+1
source

Source: https://habr.com/ru/post/1787643/


All Articles