100*_*abh 5 android broadcastreceiver android-activity google-play
我正在尝试制作一个应用程序,打开所选应用程序的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);
Run Code Online (Sandbox Code Playgroud)
但我总是在onActivityResult.StackTrace中得到结果码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.
Run Code Online (Sandbox Code Playgroud)
我想要的是市场给我一些回复,用户下载了应用程序或刚刚取消.
编辑: @CommonsWare我试图在这里访问添加的包但是无法确定从ACTION_PACKAGE_ADDED的额外内容中获取packagename的关键
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
}
}
Run Code Online (Sandbox Code Playgroud)
Android Market未设置为支持startActivityForResult().另外,请记住下载和安装是异步发生的(即,用户单击"安装",下载发生在后台,并通过它完成安装Notification).
| 归档时间: |
|
| 查看次数: |
2632 次 |
| 最近记录: |