如何使用带有回调的intent从android应用程序打开Google play store?
我正在开发一个包含应用程序列表的应用程序,我要做的是,当用户点击列表中的特定应用程序时,他将被重定向到google play store,然后下载该应用程序,如果下载成功,则在我的应用程序中显示toast消息,如果没有,则显示错误toast消息。为了验证这一点,我使用了Intent和callback,但我不知道如何回拨。请帮助我 这是我的密码:-如何使用带有回调的intent从android应用程序打开Google play store?,android,Android,我正在开发一个包含应用程序列表的应用程序,我要做的是,当用户点击列表中的特定应用程序时,他将被重定向到google play store,然后下载该应用程序,如果下载成功,则在我的应用程序中显示toast消息,如果没有,则显示错误toast消息。为了验证这一点,我使用了Intent和callback,但我不知道如何回拨。请帮助我 这是我的密码:- Uri uri = Uri.parse("https://play.google.com");// sending to Deal Website
Uri uri = Uri.parse("https://play.google.com");// sending to Deal Website
Intent i = new Intent(Intent.ACTION_VIEW, uri);
startActivity(i);
你会想用
market://details?id=<package_name>
market://details?id=
而不是
http://play.google.com/store/apps/details?id=<package_name>
http://play.google.com/store/apps/details?id=
作为链接到应用程序的url。您可以使用startActivityForResult方法
try
{
Intent viewIntent = new Intent("android.intent.action.VIEW",
Uri.parse("https://play.google.com/store/apps/details?id=your.app.id.here"));
startActivityForResult(viewIntent, 1);
}
catch(Exception e)
{
Toast.makeText(getApplicationContext(),"Unable to Connect Try Again...",Toast.LENGTH_LONG).show();
e.printStackTrace();
}
使用onActivityresult方法获得结果
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case (1):
if (resultCode == Activity.RESULT_OK)
{
//Do your stuff here
}
}
如何使回调无法使应用程序安装成功回调。您可以尝试的一个技巧是,使用startAtivityForResult并覆盖onActivityResult方法,在onActivityResult方法中,使用ActivityInfo检查设备中是否安装了特定程序包。