2017-08-31 62 views
2

您好,我正嘗試使用我的應用程序提供的字符串自動填充Google Play音樂上的搜索欄。我目前有意打開Goog​​le Play音樂,但我一直無法找到正確的參數來填充Google Play音樂上的搜索欄。 這裏是我的代碼Android意圖輸入谷歌播放音樂應用程序的搜索查詢

Intent intent = getApplicationContext().getPackageManager() 
.getLaunchIntentForPackage("com.google.android.music"); 
startActivity(intent); 

會有人知道正確的意圖是什麼?在此先感謝

+0

你確定這甚至有可能嗎?很少有活動實際接受這樣的參數。 –

+0

值得一試,我可以在Google Play商店應用中填充搜索欄。 @GabeSechan – DanielRM

回答

2

我找到了我的問題的答案。 The documentation can be found here. 我不得不選擇谷歌播放音樂作爲我的默認音樂播放器,但之後完成了歌曲搜索/自動播放與下面的代碼。

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); 
相關問題