如何在Android中使用intent with callback打开google play store。如何打开谷歌Play商店使用意图与回拨在Android?
这里是我的代码: -
Uri uri = Uri.parse("https://play.google.com");// sending to Deal Website
Intent i = new Intent(Intent.ACTION_VIEW, uri);
startActivity(i);
如何在Android中使用intent with callback打开google play store。如何打开谷歌Play商店使用意图与回拨在Android?
这里是我的代码: -
Uri uri = Uri.parse("https://play.google.com");// sending to Deal Website
Intent i = new Intent(Intent.ACTION_VIEW, uri);
startActivity(i);
此代码,如果用户去回来后安装或放弃对市场的应用工作。我希望它能帮助你。
String appPackageName = "com.application.package";
void methodThatLaunchesGooglePlay(){
try {
startActivityForResult(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)), YOUR_REQUEST_CODE);
} catch (android.content.ActivityNotFoundException anfe) {
startActivityForResult(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)), YOUR_REQUEST_CODE);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == YOUR_REQUEST_CODE){
try{
getPackageManager().getPackageInfo(appPackageName, PackageManager.GET_ACTIVITIES);
//App Installed
} catch (PackageManager.NameNotFoundException e) {
//App doesn't installed
}
}
}
在哪里调用methodThatLaunchesGooglePlay() – rahul
在你的代码中,你用startActivity()启动Google Play。将其更改为我的methodThathLaunchesGooglePlay()上的代码。 –
你在这里指的是什么回调? –
我想在这里如果应用程序成功下载然后显示吐司,如果不是,然后可能会显示错误吐司我怎么能做到这一点 – rahul