机器人:从应对市场活动 [英] android: response from market activity

查看:169
本文介绍了机器人:从应对市场活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让打开选定的应用程序和放大器的Andr​​oid Market的页面中的应用;让用户下载它。我已经用下面的意图来打开市场。

 意向意图=新的意图(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(市场://细节ID =+软件包名));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivityForResult(意向,13);
 

但我总是得到的结果code 0 onActivityResult.StackTrace说:

  I / ActivityManager(79):启动活动:意向{行为= android.intent.action.VIEW DAT =市场://细节ID = com.google.android.apps .unveil FLG = 0x10000000处CMP = com.an
droid.vending / .AssetInfoActivity}
W / ActivityManager(79):活动推出的一项新的任务,所以取消活动的结果。
 

我要的是市场回报我一些响应该用户下载的应用程序,或者只是取消了。

编辑: @CommonsWare我想在这里获得额外的包,但无法弄清楚究竟应该重点从ACTION_PACKAGE_ADDED的额外得到包名

 公共类ServiceReceiver扩展的BroadcastReceiver {
    @覆盖
    公共无效的onReceive(上下文的背景下,意图意图){
    //执行此操作时,系统发送的意图
    叠B = intent.getExtras();
    串包名= b.get(?); //不能图什么应该是关键,从群众演员拿到包名//
    }

}
 

解决方案

Android的市场不设置为支持 startActivityForResult()。另外,要记住,下载和安装异步发生(例如,用户点击安装,并且下载发生在后台,和他们完成通过通知安装)。

I am trying to make an app that opens android market page of selected app & lets user download it.I have used below intent to open market.

  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);

but I always get resultcode 0 in onActivityResult.StackTrace says:

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.

What I want is that market returns me some response that user downloaded the app or just cancelled.

EDIT: @CommonsWare I am trying to access added package here But cant figure what should be key to get packagename from extras of 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
    }

}

解决方案

The Android Market is not set up to support startActivityForResult(). Also, bear in mind that the download and installation happen asynchronously (i.e., user clicks Install, and the download occurs in the background, and they finish the install via the Notification).

这篇关于机器人:从应对市场活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆