意图额外内容未在特定设备上提供 [英] Intent extras are not being delivered on a specific device

查看:66
本文介绍了意图额外内容未在特定设备上提供的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在活动A中,我基本上有:

In Activity A I essentially have:

Long customerId = 123;
intent.putExtra("customerId", customerId);
startActivity(intent);

在活动B的onCreate()中,我有:

And in Activity B's onCreate() I have:

mCustomerId = getIntent().getLongExtra("customerId", -1);

但是对于我的一位用户(Nexus 4,Android 6.0.1),mCustomerId在活动B中解析为-1(默认值为-1).此代码对我的其他1000个用户都适用.

But for one of my users (Nexus 4, Android 6.0.1), mCustomerId resolves to -1 in Activity B (-1 being the default value). This code works fine for my other 1000 users.

同一用户在我使用的库中收到额外的意图时也有类似的问题:

This same user has a similar issue receiving an intent extra in a library I use:

https://github.com/Ereza/CustomActivityOnCrash/issues/56

这怎么会发生?

日志:

Fatal Exception: java.lang.IllegalArgumentException
Update is not supported for content://appinventor.ai_GavinGT.TipTracker_9_1_426am_ready_for_market/customers/-1
appinventor.ai_GavinGT.DeliveryTipTrackerPro_ready_for_market.data.TipProvider.update (TipProvider.java:326)
android.content.ContentProvider$Transport.update (ContentProvider.java:355)
android.content.ContentResolver.update (ContentResolver.java:1364)
appinventor.ai_GavinGT.DeliveryTipTrackerPro_ready_for_market.customer_info.CustomerProfileActivity.saveChanges (CustomerProfileActivity.java:208)
appinventor.ai_GavinGT.DeliveryTipTrackerPro_ready_for_market.customer_info.CustomerProfileActivity.access$400 (CustomerProfileActivity.java:58)
appinventor.ai_GavinGT.DeliveryTipTrackerPro_ready_for_market.customer_info.CustomerProfileActivity$6.onDebouncedClick (CustomerProfileActivity.java:137)
appinventor.ai_GavinGT.DeliveryTipTrackerPro_ready_for_market.custom_classes.DebouncedOnClickListener.onClick (DebouncedOnClickListener.java:39)
android.view.View.performClick (View.java:5204)
android.view.View$PerformClick.run (View.java:21153)
android.os.Handler.handleCallback (Handler.java:739)
android.os.Handler.dispatchMessage (Handler.java:95)
android.os.Looper.loop (Looper.java:148)
android.app.ActivityThread.main (ActivityThread.java:5420)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:726)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:616)

从日志的第二行可以看到,当客户表应为123时,将-1作为客户表的rowId插入(123仅是示例,rowId可以是大于0的任何数字).

As you can see from the second line of the log, -1 is being inserted as the rowId for the customer table when it should be 123 (123 is just an example, the rowId could be any number greater than 0).

我开始认为这个家伙可能正在ADB中闲逛我的应用程序.那可以解释为什么没有提供意图的附加内容:

I'm starting to think that this guy might be poking around my app in ADB. That would explain why the intent extras aren't being delivered:

用户正在以某种方式访问​​Pro功能在免费版本中

推荐答案

请确保您未使用标准(默认)以外的其他launchMode.如果在清单文件中的接收活动中使用launchMode属性,则必须相应地处理接收活动(如果当前任务中已经存在活动,则可能必须重写onNewIntent方法). 有关更多信息,请阅读此文档- https://developer.android.com/guide/components/活动/任务和后退堆栈

Make sure you are not using any launchMode other than standard(default). If you are using launchMode attribute in receiving activity in Manifest file, then you have to deal with receiving activity accordingly (maybe you have to override onNewIntent method if activity already exist in the current task). For more information read this documentation - https://developer.android.com/guide/components/activities/tasks-and-back-stack

这篇关于意图额外内容未在特定设备上提供的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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