ClassNotFoundException的在android.util.ArrayMap里面意向 [英] ClassNotFoundException in android.util.ArrayMap inside Intent
问题描述
我是开发一个Android应用程序,并在部分之一,我通过使用一个Intent数据从一个datepicker对话片段回,使用getTargetFragment()创建它的片段。onActivityResult(INT targetRequest code,INT结果code,意图意图)。我加入三个整数(日,月,年)从日历片段提取到的意图传递。然后我读创建它的片段的onActivityResult()方法,在此意图。一切正常,因为它应该,一切都很好,很正常,世界是生活在一个完美的地方。
I was developing an Android app and in one of the sections, I pass data using an Intent from a DatePicker dialog fragment back to the fragment that created it using getTargetFragment().onActivityResult(int targetRequestCode, int resultCode, Intent intent). I am adding three integers (date, month and year) extracted from the Calendar fragment to the intent being passed. And then I read this intent within the onActivityResult() method of the fragment that created it. Everything works as it should and all is fine and dandy and the world is a perfect place to live in.
当我试图调试,我犯了一个愚蠢的错误,我注意到一些有趣的事情。当我展开意图的内容,我觉得我的数据是一个捆绑的预期。但是,我看到有意向在另一个对象调用android.util.ArrayMap大小为3。
While I was trying to debug a silly error that I had made, I noticed something interesting. When I expand the content of the intent, I find that my data is in a bundle as expected. But I see that there is another object within the intent called android.util.ArrayMap with size 3.
此大小似乎对应于我把在意图(Ⅰ通过添加额外的虚设参数测试它)数据的数量。当我展开ArrayMap的内容,我看到它抛出一个ClassNotFoundException。为什么会做到这一点。密钥类型为String,值类型为整型(我把一个int,但我不认为它很重要,因为我加入的String键和值,它仍然抛出异常)。我扩大了ArrayMap细节,但它似乎没有什么意义。
This size seems to correspond to the number of data that I put in the intent (I tested it by adding additional dummy parameters). when I expand the contents of the ArrayMap, I see that it throws a ClassNotFoundException. Why would it do this. The key type is String and the value type is Integer (I am putting an int but I don't think it matters as I added in String for key and value and it still threw the exception). I expanded the ArrayMap details but it did not seem to make sense.
我的问题是:
- 这是为什么ClassNotFoundException的发生?
- 什么是摆在首位的必要性ArrayMap?
推荐答案
你的 putExtra
值保存在捆绑
的内部数据结构,这恰好是 ArrayMap
your putExtra
values are saved inside Bundle
's internal data structure , which happens to be ArrayMap
// Invariant - exactly one of mMap / mParcelledData will be null
// (except inside a call to unparcel)
/* package */ ArrayMap<String, Object> mMap = null;
我想这将您 INT
来一个更通用的对象
类。
I guess it converts your int
to a more generic Object
class.
ClassNotFoundException的
可能是IDE /调试窗口的问题,因为没有任何其他的自定义类在这里的这个数据结构。此外,你是<一个href="http://developer.android.com/reference/android/content/Intent.html#putExtra(java.lang.String,%20int)"相对=nofollow>预计将使用包名preFIX在名称
,这里提到
ClassNotFoundException
could be IDE/debug window issue, as there is not any other custom class here for this data structure. Also, you are expected to use package-name prefix in your name
, as mentioned here
The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
这篇关于ClassNotFoundException的在android.util.ArrayMap里面意向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!