I am having trouble inserting a passed String from an intent into the google music app's searchbar.
The following code allows me to open up Google Play Music from my app, but leaves the searchbar empty. Would anyone know how to populate Google Play Music's searchbar with my passed in String? any help would be greatly appreciated.
Intent intent = getActivity().getPackageManager().getLaunchIntentForPackage("com.google.android.music");
intent.putExtra(song ,"song to be inserted in google play searchbar");
startActivity(intent);
I have figured it out thanks to the following documentation
In this example, i am opening up the google play store then entering search?q=drake&c=music")); as part of the URI to go to the music tab and search for drake
Intent i = new Intent(android.content.Intent.ACTION_VIEW);
i.setData(Uri.parse("http://play.google.com/store/search?q=drake&c=music"));
startActivity(i);
Related
How can i implement share button of soundcloud which share a link of audio track and when user click on it open this track with soundcloud application.
I searched but i didn't find any thing all of them share audio or image or text or application, so any help of how can i do that.
Thanks in advance.
See this for adding sound from Soundcloud app.
See this for accessing Soundcloud to play song in Soundcloud
This code from enadun may help:
String id = "114143409"; //Track id
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("soundcloud://sounds:" + id));
startActivity(intent);
Hello i am trying to automatically fill the search bar on Google Play Music with a String that my app provides. I currently have the intent to open Google Play Music, but I have not been able to find the right params to fill the search bar on Google Play Music.
Here is my code
Intent intent = getApplicationContext().getPackageManager()
.getLaunchIntentForPackage("com.google.android.music");
startActivity(intent);
Would anyone know the right intent? Thanks in advance
I found the answer to my question.
The documentation can be found here.
I had to choose google play music as my default music player, but after that was done the songs were searched for/played automatically with the following code.
Intent intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
intent.putExtra(MediaStore.EXTRA_MEDIA_ARTIST, track.getArtistName());
intent.putExtra(MediaStore.EXTRA_MEDIA_TITLE, track.getName());
intent.putExtra(SearchManager.QUERY, track.getName());
startActivity(intent);
Below is the working code to play a song with given title.
String title = "Iridescent";
Intent intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
intent.putExtra(MediaStore.EXTRA_MEDIA_FOCUS,
MediaStore.Audio.Artists.ENTRY_CONTENT_TYPE);
intent.putExtra(MediaStore.EXTRA_MEDIA_TITLE,title);
intent.putExtra(SearchManager.QUERY,title);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}
I'm trying to play a known playlist in the Spotify app. The best I've got is to load the playlist, but not play it.
Two things I've tried. Firstly to play from search:
Intent intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
intent.setComponent(new ComponentName("com.spotify.music",
"com.spotify.music.MainActivity"));
intent.putExtra(MediaStore.EXTRA_MEDIA_FOCUS,
MediaStore.Audio.Playlists.ENTRY_CONTENT_TYPE);
intent.putExtra(MediaStore.EXTRA_MEDIA_PLAYLIST, <PLAYLIST>);
intent.putExtra(SearchManager.QUERY, <PLAYLIST>);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
I've tried replacing PLAYLIST with the name of a known playlist. Also tried things like "4Rj0zQ0Ux47upeqVSIuBx9", "spotify:user:11158272501:playlist:4Rj0zQ0Ux47upeqVSIuBx9" etc. All these do is a failed search for these strings.
Second attempt is the View intent:
String uri = "https://play.spotify.com/user/11158272501/playlist/4Rj0zQ0Ux47upeqVSIuBx9";
Intent intent= new Intent( Intent.ACTION_VIEW, Uri.parse(uri) );
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
This loads the playlist, but does not play. If I then use one of the many ways to send a KEYCODE_MEDIA_PLAY key, it just resumes the currently playing list, not this newly loaded list.
Any help from anyone (including Spotify devs)?
BTW I don't want to use the Spotify SDK to implement my own Spotify Player - it seems a shame to have to do this when a perfectly good player is already installed on a user's device.
I found the answer from this blog. What I was missing was the playlist URI as a data Uri in the intent. So not using the proper Android way of Play from search.
So, using the first method from the question, you end up with this:
Intent intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
intent.setData(Uri.parse(
"spotify:user:11158272501:playlist:4Rj0zQ0Ux47upeqVSIuBx9"));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
3 things to note:
the Uri can't be the https://play.spotify... but has to be the colon seperated type.
the Spotify account must be premium, otherwise the playlist opens but does not play.
this does not work if the screen is off, or lock screen is showing. The spotify activity needs to display on the screen before it loads and plays!
This final point means it isn't actually usable for me... so not accepting answer yet.
Just add :play to Spotify Intent URI
spotify:album:3avifwTCXoRzRxxGM1O0eN:play
I use this URI to search the Play Store, but the Android docs don't mention a way to search a specific category like, games, music, or books.
URI marketUri = Uri.parse("market://search?q= ");
The Play Books and Play Music apps both open the Play Store app to their correct categories, so if they can open to a specific catergory, then I think I can search one. Does anyone have some info on doing this?
I found the solution. Here's the current method I'm using to shop the music category.
public static void shopFor(Context context, String artistName) {
String str = "https://market.android.com/search?q=%s&c=music&featured=MUSIC_STORE_SEARCH";
Intent shopIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format(str, Uri.encode(artistName))));
shopIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shopIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivity(shopIntent);
}
I did a search at play.google.com in the books category and the URL looks like this:
https://play.google.com/store/search?q=android&c=books
try adding "&c=books" after your query and see what happens.
I want to create a android search application that can be used to search a video from youtube for given word.
how do I do that. please someone give me a tutorial link. Thanks
Please try the below code .
Intent intent = new Intent(Intent.ACTION_SEARCH);
intent.setPackage("com.google.android.youtube");
intent.putExtra("query", "Android");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
use this API for Searching a Video on Youtube
https://gdata.youtube.com/feeds/api/videos?q=india
where q is word you want to search related videos
for more detail see YouTube APIs