轉自:http://www.jianshu.com/p/a4a806567368
需求:
從App內部點擊按鈕或鏈接,跳轉到應用商店的某個APP的詳情頁面。
讓用戶 下載 或 評論。
實現:
/**
* 啓動到應用商店app詳情界面
*
* @param appPkg 目標App的包名
* @param marketPkg 應用商店包名 ,如果爲""則由系統彈出應用商店列表供用戶選擇,否則調轉到目標市場的應用詳情界面,某些應用商店可能會失敗
*/
public void launchAppDetail(String appPkg, String marketPkg) {
try {
if (TextUtils.isEmpty(appPkg)) return;
Uri uri = Uri.parse("market://details?id=" + appPkg);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
if (!TextUtils.isEmpty(marketPkg)) {
intent.setPackage(marketPkg);
}
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
注意:如果 應用商店包名爲空 就會將手機上已下載的應用商店都列出來,讓你選擇一個進行跳轉。
主流應用商店對應的包名如下:
包名 | 商店 |
---|---|
com.android.vending | Google Play |
com.tencent.android.qqdownloader | 應用寶 |
com.qihoo.appstore | 360手機助手 |
com.baidu.appsearch | 百度手機助 |
com.xiaomi.market | 小米應用商店 |
com.wandoujia.phoenix2 | 豌豆莢 |
com.huawei.appmarket | 華爲應用市場 |
com.taobao.appcenter | 淘寶手機助手 |
com.hiapk.marketpho | 安卓市場 |
cn.goapk.market | 安智市場 |
列出 Google GMS 各個apk的包名和類名,記錄一下:
此處轉自:
http://blog.csdn.net/zheng_buding/article/details/42149379
Facebook [com.facebook.katana / com.facebook.katana.LoginActivity]
Chrome [com.Android.chrome / com.google.android.apps.chrome.Main]
Gmail [com.google.android.gm / com.google.android.gm.ConversationListActivityGmail]
Google+ [com.google.android.apps.plus / com.google.android.apps.plus.phone.HomeActivity]
Maps [com.google.android.apps.maps / com.google.android.maps.MapsActivity]
Play Movies [com.google.android.videos / com.google.android.youtube.videos.EntryPoint]
Play Books [com.google.android.apps.books / com.google.android.apps.books.app.BooksActivity]
Play Games [com.google.android.play.games / com.google.android.gms.games.ui.destination.main.MainActivity]
Drive [com.google.android.apps.docs / com.google.android.apps.docs.app.NewMainProxyActivity]
YouTube [com.google.android.youtube / com.google.android.apps.youtube.app.WatchWhileActivity]
Photos [com.google.android.apps.plus / com.google.android.apps.plus.phone.ConversationListActivity]
Hangouts [com.google.android.talk / com.google.android.talk.SigningInActivity]
Play Store [com.android.vending / com.android.vending.AssetBrowserActivity]
Opera Mini [com.opera.mini.android / com.opera.mini.android.Browser]
Deezer [deezer.android.app / com.deezer.android.ui.activity.LauncherActivity]
鏈接到 Google Play 的一些額外方法
https://developer.android.com/distribute/tools/promote/linking.html
結果 | 網頁鏈接 | Android 應用鏈接(Google Play) |
---|---|---|
顯示特定應用的商品詳情頁 | http://play.google.com/store/apps/details?id=<package_name> | market://details?id=<package_name> |
顯示特定發佈者的應用 | http://play.google.com/store/search?q=pub:<publisher_name> | market://search?q=pub:<publisher_name> |
使用常規字符串查詢搜索應用 | http://play.google.com/store/search?q=<query> | market://search?q=<query> |