繁体   English   中英

如何将搜索字符串从另一个应用程序传输到android上的音乐应用程序

[英]How to transfer a search string to music apps on android from another app

我正在开发一个用于Android的应用程序,该应用程序需要其他音乐应用程序,并且我想从我的应用程序转移到我要搜索字符串的音乐应用程序(例如:“ Thriller by Michael Jackson”)。 我知道Google的Android语音搜索以及Dragon个人助手都可以做到这一点。 我不控制音乐应用程序接受什么,仅控制我的应用程序通过我开始新活动时正在创建的意图发送的内容。 有谁知道如何做到这一点? 谢谢。

您可以通过捆绑将搜索字符串从您的活动传递到您要打开的音乐应用活动。

Intent i = new Intent(//Insert required action for the activity you want to open);
 // you should get the text from a widget like editText here
 String searchString ="Thriller by Michael Jackson";
 //Create a bundle
 Bundle bundle = new Bundle();
 //add the search string to the bundle 
 bundle.putString("SEARCH_STRING",searchString);
 //add bundle to intent
 i.putExtras(bundle);
 //call the music app's activity
 startActivity(i);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM