Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting an Spotify intent

I want my app to open spotify links and send people to the app. If the app is installed, this works wonders:

final Intent intent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("spotify:album:7rt7AxYexFTtdEqaJPekvX"));

However, there will be cases where the app is not installed yet, so I'll want them to download it from Google Play with this other intent:

final Intent intent = new Intent(
                    Intent.ACTION_VIEW,
                    Uri.parse("https://play.google.com/store/apps/details?id=com.spotify.mobile.android.ui"));

However, I really want it to be installed directly from Google Play instead of letting people to choose which app to open... if Google Play is installed. If Google Play is missing, I want them to choose which app to open (often it will be a navigator, but whatever)

Is there a way to do this?

like image 434
Charlie-Blake Avatar asked Oct 23 '22 05:10

Charlie-Blake


1 Answers

However, I really want it to be installed directly from Google Play instead of letting people to choose which app to open

Use the market:// Uri instead of the https:// Uri: http://developer.android.com/distribute/googleplay/promote/linking.html

Also, please only use the spotify: scheme if that is publicly documented and supported.

like image 186
CommonsWare Avatar answered Nov 04 '22 00:11

CommonsWare