parcelable

Crash when reading nested Parcelable

折月煮酒 提交于 2019-12-06 06:21:55
I have a class that extends Parcelable. It has a member variable which is an ArrayList of another class which also extends Parcelable. I pass the MyClass1 object in an Intent back to an Activity and read it in. When the constructor reaches in.readTypedList, the app crashes with the following error: 04-11 14:19:11.223: E/AndroidRuntime(502): Uncaught handler: thread main exiting due to uncaught exception 04-11 14:19:11.234: E/AndroidRuntime(502): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=Intent { (has extras) }} to activity {com

Pendingintent getbroadcast lost parcelable data

爱⌒轻易说出口 提交于 2019-12-06 05:01:29
问题 Here is the problem. My program is running perfect in Android 6.0. After update the device to android 7.0. Pendingintent can not pass the parcelable data to boradcast reveiver. Here is the code. Fire the alarm public static void setAlarm(@NonNull Context context, @NonNull Todo todo) { AlarmManager alarmManager = (AlarmManager) context.getSystemService(context.ALARM_SERVICE); Intent intent = new Intent(context, AlarmReceiver.class); intent.putExtra("KEY_TODO", todo); PendingIntent alarmIntent

Passing an object from one application to another in android

泄露秘密 提交于 2019-12-06 03:11:33
After lot of googeling, I could not find any way to pass a object from one application to other application.Though I know that we can pass object from one activty to other activity using Parcel but how to do this between applications? My object is this public class MyObject { private String name; public String getName() { return this.name; } public void setName(String name) { this.name=name; } } Then how to do this like we do for passing object between activities intent.putExtra("key",new MyOject()); I'm assuming you're in charge of both applications. Which of these situations is true? Both

How to send an object containing drawable objects from one android activity to another using intents?

你离开我真会死。 提交于 2019-12-05 22:11:53
I've gone through this: How to send an object from one Android Activity to another using Intents? But i'm facing problem in sending images in the object to the other activity. Please help. Convert your Drawable to Bitmap and send it to Another Activity. Bitmap bitmap = ((BitmapDrawable)d).getBitmap(); To send, intent.putExtra("Bitmap", bitmap); To Fetch, Bitmap bitmap = (Bitmap)this.getIntent().getParcelableExtra("Bitmap"); Well you can't really send images with intents since you can attach as extras to intents only Serializable objects. But you can store images (in memory in different

onSaveInstanceState() vs. onRetainCustomNonConfigurationInstance()

十年热恋 提交于 2019-12-05 21:52:27
I am using ActionBarSherlock, along with several MenuItem s that I dynamically manage, depending on program state. Specifically, I save the MenuItem s into instance variables in the Activity 's onCreateOptionsMenu() method, and then can show and/or hide them as needed later in the Activity . However, I found that the MenuItem variables can be lost on configuration changes, such as device rotation. So I also put them into a Parcel and pass them to onSaveInstanceState() for restoral through the savedInstanceState mechanism in the next onCreate() call, if needed. This seems to work fine in the

How to marshal/unmarshal ContentValues to insert generic type into ContentProvider?

半腔热情 提交于 2019-12-05 19:00:21
I want to put a generic POJO into ContentValues and unmarshall it within the ContentProvider. I've been wracking my tiny brain re: Parcelables, ContentValues, and inserting into SQLite Regarding: http://njzk2.wordpress.com/2013/05/31/map-to-contentvalues-abusing-parcelable/ How to write a common code for inserting data in android's Sqlite I've been trying to insert a android.location.Location into SQLite via ContentProvider: Location loc = mLocationClient.getLastLocation(); myParcel = android.os.Parcel.obtain(); loc.writeToParcel(myParcel, 0); ContentValues values = ContentValues.CREATOR

Getting NullPointerException: Attempt to get length of null array in Parcelable when trying to read a byte array in Android

淺唱寂寞╮ 提交于 2019-12-05 18:35:24
问题 I have a class that implements the Parcelable. All my values are set ok through the writeToParcel method but when reading within the constructor I have a problem with a byte array that throws NullPointerException: public final class Product implements Parcelable { private Integer ID; private byte[] image; // Constructors public Product(){} public Product(Parcel source) { this.ID = source.readInt(); source.readByteArray(this.image); } public int describeContents() { return this.hashCode(); }

Can Nulls be passed to parcel?

谁说胖子不能爱 提交于 2019-12-05 12:03:59
Is it possible to write null to Parcel when parcelling an object, and get null back again when unparcelling it again? Let's assume we have the following code: public class Test implements Parcelable { private String string = null; public Test(Parcel dest, int flags) { source.writeString(string); } } Will I get a NullPointerException when reading this value back from the parcel using Parcel.readString() ? Or will I get a null value out? Richard Le Mesurier Yes, you can pass a null to the Parcel.writeString(String) method. When you read it out again with Parcel.readString() , you will get a null

How to pass object which contain Bitmap to another activity

烂漫一生 提交于 2019-12-05 11:58:53
so I am kind of new in Android Developing, I was trying to make a Sign-up Activity ( UserPrivateInfoSignUpActivity.java ) that load a picture (Bitmap) and create a UserPersona Object that I want to pass into another Activity ( UserGeneralDataSignUpActivity ). I did a research for solutions and somehow I am still unable to pass the Bitmap image although it is already implements Parcelable . Any suggestions? Here is my code (without getters & setters) PersonaUser.java: public class PersonaUser implements Parcelable{ private String puName; private String puEmailAddress; private String puCountry;

Android: ParcelFileDescriptor “createpipe” method 64KB error

梦想与她 提交于 2019-12-05 07:01:43
问题 I have an app that uses the ContentProvider class. In the openFile method, I need to be able to decode a file & return as a stream of data. So I decided to use the built in pipe. The problem is If I use the createPipe method, I am able to write only 64KB into it. After that I am unable to write data into the Pipe. Also note that I cannot read until the data is fully decoded & written into the pipe. package com.aujas.html.viewer.content; public class LocalFileContentProvider extends