android:市场活动的反应

2023-12-24

我正在尝试制作一个应用程序,打开所选应用程序的 Android 市场页面并让用户下载它。我已使用以下意图来打开市场。

  Intent intent = new Intent (Intent.ACTION_VIEW);
    intent.setData (Uri.parse ("market://details?id=" + PackageName ));
    intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivityForResult (intent, 13);

但我总是在 onActivityResult.StackTrace 中得到 resultcode 0 说:

I/ActivityManager(   79): Starting activity: Intent { act=android.intent.action.VIEW dat=market://details?id=com.google.android.apps.unveil flg=0x10000000 cmp=com.an
droid.vending/.AssetInfoActivity }
W/ActivityManager(   79): Activity is launching as a new task, so cancelling activity result.

我想要的是市场向我返回一些用户下载应用程序或刚刚取消的响应。

EDIT:@CommonsWare我试图在这里访问添加的包但无法弄清楚从 ACTION_PACKAGE_ADDED 的额外部分获取包名的关键是什么

public class ServiceReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
    //Do this when the system sends the intent
    Bundle b = intent.getExtras();
    String packagename = b.get(?);   //cant figure what should be key to get packagename //from extras
    }

}

Android Market 尚未设置为支持startActivityForResult()。另外,请记住,下载和安装是异步发生的(即,用户单击“安装”,下载在后台进行,然后他们通过Notification).

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

android:市场活动的反应 的相关文章

随机推荐