Parcel Unmarshalling,抛出运行时异常(Parcel Unmarshalling, Runtime Exception is thrown)
我试图创建一个显示周期表的应用程序然后你可以点击每个元素带你到另一个屏幕看它的摩尔质量。 从那里你可以去另一个屏幕。 问题是每当我点击一个元素,而不是进入下一个屏幕时,我会得到一个运行时异常。 这将打印在堆栈跟踪中。 我如何解决这个问题,我仔细检查了Element类中实现parcelable的所有内容是否正确完成
03-15 14:26:01.714: E/AndroidRuntime(11104): FATAL EXCEPTION: main 03-15 14:26:01.714: E/AndroidRuntime(11104): Process: com.example.androidhive, PID: 11104 03-15 14:26:01.714: E/AndroidRuntime(11104): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidhive/com.example.thecookieclub.Home}: java.lang.RuntimeException: Parcel android.os.Parcel@382eb178: Unmarshalling unknown type code 3014757 at offset 300 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread.access$800(ActivityThread.java:144) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Handler.dispatchMessage(Handler.java:102) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Looper.loop(Looper.java:135) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread.main(ActivityThread.java:5221) 03-15 14:26:01.714: E/AndroidRuntime(11104): at java.lang.reflect.Method.invoke(Native Method) 03-15 14:26:01.714: E/AndroidRuntime(11104): at java.lang.reflect.Method.invoke(Method.java:372) 03-15 14:26:01.714: E/AndroidRuntime(11104): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 03-15 14:26:01.714: E/AndroidRuntime(11104): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 03-15 14:26:01.714: E/AndroidRuntime(11104): Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@382eb178: Unmarshalling unknown type code 3014757 at offset 300 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Parcel.readValue(Parcel.java:2222) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Parcel.readListInternal(Parcel.java:2520) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Parcel.readArrayList(Parcel.java:1836) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Parcel.readValue(Parcel.java:2167) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Parcel.readArrayMapInternal(Parcel.java:2479) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.BaseBundle.unparcel(BaseBundle.java:221) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Bundle.getParcelableArrayList(Bundle.java:848) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.content.Intent.getParcelableArrayListExtra(Intent.java:4868) 03-15 14:26:01.714: E/AndroidRuntime(11104): at com.example.thecookieclub.Home.onCreate(Home.java:37) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.Activity.performCreate(Activity.java:5933) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251) 03-15 14:26:01.714: E/AndroidRuntime(11104): ... 10 more
万一我错过了什么,这里是实现Parcelable的类
public class Element implements Parcelable { private double molarMass; private String name; private int ID; private String symbol; public Element (String elementName, int a, double mass, String sym){ name=elementName; molarMass=mass; ID= a; symbol=sym; } public Element(Parcel in) { name=in.readString(); symbol=in.readString(); ID=in.readInt(); molarMass=in.readDouble(); } public String getName (){ return name; } public double getMass (){ return molarMass; } public int getID (){ return ID; } public String getSymbol (){ return symbol; } public static final Parcelable.Creator<Element> CREATOR = new Parcelable.Creator<Element>() { public Element createFromParcel(Parcel in) { return new Element(in); } public Element[] newArray(int size) { return new Element[size]; } }; @Override public int describeContents() { // TODO Auto-generated method stub return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString (name); dest.writeInt (ID); dest.writeDouble (molarMass); dest.writeString (symbol); } /*public double calculate (double massInGrams){ double as=massInGrams/molarMass; return as;
} * /
}
I tried to make an app that would display the periodic table and then you could click each element to take you to another screen to see its molar mass. From there you can go to another screen. The problem is that whenever I click on an element, instead of going to the next screen I get a runtime exception. This is printed in the stack trace. How do I solve the problem, I double checked that everything in the Element class which implements parcelable was done correctly
03-15 14:26:01.714: E/AndroidRuntime(11104): FATAL EXCEPTION: main 03-15 14:26:01.714: E/AndroidRuntime(11104): Process: com.example.androidhive, PID: 11104 03-15 14:26:01.714: E/AndroidRuntime(11104): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidhive/com.example.thecookieclub.Home}: java.lang.RuntimeException: Parcel android.os.Parcel@382eb178: Unmarshalling unknown type code 3014757 at offset 300 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread.access$800(ActivityThread.java:144) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Handler.dispatchMessage(Handler.java:102) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Looper.loop(Looper.java:135) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread.main(ActivityThread.java:5221) 03-15 14:26:01.714: E/AndroidRuntime(11104): at java.lang.reflect.Method.invoke(Native Method) 03-15 14:26:01.714: E/AndroidRuntime(11104): at java.lang.reflect.Method.invoke(Method.java:372) 03-15 14:26:01.714: E/AndroidRuntime(11104): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 03-15 14:26:01.714: E/AndroidRuntime(11104): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 03-15 14:26:01.714: E/AndroidRuntime(11104): Caused by: java.lang.RuntimeException: Parcel android.os.Parcel@382eb178: Unmarshalling unknown type code 3014757 at offset 300 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Parcel.readValue(Parcel.java:2222) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Parcel.readListInternal(Parcel.java:2520) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Parcel.readArrayList(Parcel.java:1836) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Parcel.readValue(Parcel.java:2167) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Parcel.readArrayMapInternal(Parcel.java:2479) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.BaseBundle.unparcel(BaseBundle.java:221) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.os.Bundle.getParcelableArrayList(Bundle.java:848) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.content.Intent.getParcelableArrayListExtra(Intent.java:4868) 03-15 14:26:01.714: E/AndroidRuntime(11104): at com.example.thecookieclub.Home.onCreate(Home.java:37) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.Activity.performCreate(Activity.java:5933) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) 03-15 14:26:01.714: E/AndroidRuntime(11104): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251) 03-15 14:26:01.714: E/AndroidRuntime(11104): ... 10 more
Just in case I missed something, here is the class which implements Parcelable
public class Element implements Parcelable { private double molarMass; private String name; private int ID; private String symbol; public Element (String elementName, int a, double mass, String sym){ name=elementName; molarMass=mass; ID= a; symbol=sym; } public Element(Parcel in) { name=in.readString(); symbol=in.readString(); ID=in.readInt(); molarMass=in.readDouble(); } public String getName (){ return name; } public double getMass (){ return molarMass; } public int getID (){ return ID; } public String getSymbol (){ return symbol; } public static final Parcelable.Creator<Element> CREATOR = new Parcelable.Creator<Element>() { public Element createFromParcel(Parcel in) { return new Element(in); } public Element[] newArray(int size) { return new Element[size]; } }; @Override public int describeContents() { // TODO Auto-generated method stub return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString (name); dest.writeInt (ID); dest.writeDouble (molarMass); dest.writeString (symbol); } /*public double calculate (double massInGrams){ double as=massInGrams/molarMass; return as;
}*/
}
原文:https://stackoverflow.com/questions/29068244
最满意答案
是的,Android TV支持FCM。 图书馆和实施是一样的。
但是,由于电视机没有系统栏,因此它与平板电脑的功能不同。 在系统自动在系统栏上显示通知的情况下,它什么都不做。
在你的特定情况下,它会正常工作,因为你想要总是获得FCM消息,然后在后台处理它。
Yes, Android TV supports FCM. Libraries and implementation are the same.
However, it does not work the same as for phones as tablets, since the TV does not have a system bar. On the cases where the system will automatically display the notification on the system bar, it does nothing.
In your particular case, it will work fine, since you want to always get the FCM message and then process it on the background.
相关问答
更多-
是的,你可以这样做 。 使用FLAG_ONGOING_EVENT http://developer.android.com/reference/android/app/Notification.html#FLAG_ONGOING_EVENT Notification notification = new Notification(icon, tickerText, when); notification.flags = Notification.FLAG_ONGOING_EVENT; 要 ...
-
哦,是的! 它被称为C2DM 。 检查出来! 编辑: 教程链接添加! 编辑:为了完整起见,C2DM现在已被弃用,以支持Google Cloud Messaging 编辑:GCM现在已被Firebase云消息传递取代 Oh yes! Its called C2DM. Do check it out! Edit: Tutorial link added! Edit: For completeness, C2DM has now been deprecated in favor of Google Cloud M ...
-
为了更改按钮的状态,即使将动作添加到适配器之后,您也需要通知对具有Action的适配器的更改。 mPlayPauseAction.nextIndex(); // next index, if it was pause, it'll be play notifyChanged(mPlayPauseAction); // where notifyChanged(Action action) is: private void notifyChanged(Action action) { ArrayObj ...
-
是的,Android TV支持FCM。 图书馆和实施是一样的。 但是,由于电视机没有系统栏,因此它与平板电脑的功能不同。 在系统自动在系统栏上显示通知的情况下,它什么都不做。 在你的特定情况下,它会正常工作,因为你想要总是获得FCM消息,然后在后台处理它。 Yes, Android TV supports FCM. Libraries and implementation are the same. However, it does not work the same as for phones as ta ...
-
我们无法区分推送类型,因此这不是一个真正的选择。 We have no way to distinguish push types so that's not really an option.
-
推送Android的通知(Push notification for android)[2024-01-10]
只需通过某些列将设备的registration_id记录到数据库中即可区分出来, 并在发送推送时选择某些registration_ids。 Just distinguish device's registration_id when you record them into your database by certain column, and select certain registration_ids when you send push . -
包含2个模块的Android TV应用,排除在Google Play中(Android TV app with 2 modules, exclusion in Google Play)[2024-01-10]
现在解决,我收到来自Google支持团队的快速回复,我的应用程序现已被接受投入生产。 任何文件(gradle或manifest)都没有变化。 Solved now, i received à quick answer from Google support team, my app is now accepted in production. No changes in any file (gradle or manifest). -
对于第一个问题,是的,可以使用YouTube Android Player API 。 对于第二个问题,您可以使用此处提到的createSearchIntent 您还可以参考相关问题, 在Android TV中使用Youtube API For first question, yes, it is possible using YouTube Android Player API. For second question, you may use createSearchIntent mentioned i ...
-
Google TV Addon Android模拟器低空间通知(Google TV Addon Android Emulator Low Space Notification)[2022-10-15]
我遇到了同样的问题,我认为这是一个错误。 我在这里创建了一个错误报告: http : //code.google.com/p/android/issues/detail?id = 33697 随意加注星标并添加评论/信息。 I'm suffering the same issue and I think this is a bug. I've created a bug report here: http://code.google.com/p/android/issues/detail?id=33697 ... -
基本上...没有。 Chromecast允许您在电视上放置网页,然后允许您的设备与该网页进行通信。 而已。 您可以在收到推送通知时打开Chromecast应用...或通知已在运行的Chromecast接收器应用,但是当您没有运行应用时,无法影响屏幕上显示的内容。 Basically...no. Chromecast allows you to put a web page on your TV and then allows your device to communicate with that web ...