我已经编写了代码以列出所有安装的应用程序。我有一个按钮事件,它将被重定向到Google Store中特定的应用主页。然而,我无法成功地将它们重定向。这是我使用的代码。我在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())));
}
}
提前致谢
context = this; context.getPackageName()
,你需要使用另一个应用程序的包名。 - SMR