【发布时间】:2015-10-14 07:04:33
【问题描述】:
我编写了一个代码来列出所有已安装的应用程序。我有一个按钮事件,它将被重定向到 Google 商店中的特定 App 主页。但是我无法成功重定向它们。这是我使用的代码。我没有在 uri 中获取应用程序的包名称,因此我得到 “在服务器上找不到 URL”。请提出您的宝贵建议。
public void update(View view) {
Context context = this;
Uri uri = Uri.parse("http://play.google.com/store/apps/details?id=" + context.getPackageName());
Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
// To count with Play market backstack, After pressing back button,
// to taken back to our application, we need to add following flags to intent.
try {
startActivity(goToMarket);
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/details?id=" + context.getPackageName())));
}
}
提前致谢
【问题讨论】:
-
你使用的是自己app的pkg名
context = this; context.getPackageName()你需要使用其他app的包名 -
您好,感谢您的建议。如何动态设置上下文以重定向到其他应用程序的包名
-
我认为this 是您所需要的。不是上下文。
标签: android android-intent android-manifest