如何在android中使用intent和call-back打开Google play商店?
如何在android中使用intent和callback打开google play商店 这是我的密码:-如何在android中使用intent和call-back打开Google play商店?,android,Android,如何在android中使用intent和callback打开google play商店 这是我的密码:- Uri uri = Uri.parse("https://play.google.com");// sending to Deal Website Intent i = new Intent(Intent.ACTION_VIEW, uri); startActivity(i); 如果用户在安装后返回或放弃市场上的应用程序,则此代码有效。我希望
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
}
}
}
你在这里指的是什么回调?我想在这里,如果应用程序下载成功,然后显示toast,如果不成功,则可能显示错误toast我该如何做在哪里调用启动GooglePlay()的方法在你的代码中,你使用startActivity()启动Google Play。将其更改为my methodThathLaunchesGooglePlay()上的代码。