android 如何实现apk search出现在系统的推荐列表里

来源:互联网 发布:淘宝厚底鞋 编辑:程序博客网 时间:2024/06/07 08:00

经常出现在系统提示要安装apk或者插件时,会默认打开一系列市场或者其他程序,如何让自己的程序也出现在这些列表里?
答案是,在系统的启动activity的intent-filter描述里加上search过滤
<intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
   </intent-filter>
   <intent-filter>
    <action android:name="android.intent.action.SEARCH" />
    <category android:name="android.intent.category.DEFAULT" />
   </intent-filter>

   <intent-filter android:priority="100">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="http" android:host="market.iworks.com"
     android:path="/search" />
    <data android:scheme="market" android:host="search"
     android:path="" />
   </intent-filter>

 

要测试的话,可使用如下代码启动

 

Market 相关
1.        //寻找某个应用
2.        Uri uri = Uri.parse("market://search?q=pname:pkg_name");
3.        Intent it = new Intent(Intent.ACTION_VIEW, uri); 
4.        startActivity(it); 
5.        //where pkg_name is the full package path for an application
1.        //显示某个应用的相关信息
2.        Uri uri = Uri.parse("market://details?id=app_id"); 
3.        Intent it = new Intent(Intent.ACTION_VIEW, uri);
4.        startActivity(it); 
5.        //where app_id is the application ID, find the ID  
6.        //by clicking on your application on Market home  
7.        //page, and notice the ID from the address bar

 

其中pkg_name 就是要下载的应用的包名, 假如要在lanchuer中点击某个ICON跳转到应用详情页,就可以通过这种方式

原创粉丝点击