问题描述
您好,我正在尝试使用我的应用程序提供的字符串自动填充Google Play音乐上的搜索栏.我目前打算打开Google Play音乐,但无法找到合适的参数来填充Google Play音乐上的搜索栏.这是我的代码
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
推荐答案
我找到了问题的答案.可在此处找到文档. 我必须选择Google Play音乐作为我的默认音乐播放器,但此操作完成后,将使用以下代码自动搜索/播放歌曲.
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);
这篇关于Android打算为Google Play音乐应用输入搜索查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!