parcelable

Extract notification text from parcelable, contentView or contentIntent

馋奶兔 提交于 2019-11-26 11:47:56
问题 So I got my AccessibilityService working with the following code: @Override public void onAccessibilityEvent(AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) { List<CharSequence> notificationList = event.getText(); for (int i = 0; i < notificationList.size(); i++) { Toast.makeText(this.getApplicationContext(), notificationList.get(i), 1).show(); } } } It works fine for reading out the text displayed when the notifcation was created (1

How to read/write a boolean when implementing the Parcelable interface?

让人想犯罪 __ 提交于 2019-11-26 11:45:03
问题 I\'m trying to make an ArrayList Parcelable in order to pass to an activity a list of custom object. I start writing a myObjectList class which extends ArrayList<myObject> and implement Parcelable . Some attributes of MyObject are boolean but Parcel don\'t have any method read/writeBoolean . What is the best way to handle this? 回答1: Here's how I'd do it... writeToParcel: dest.writeByte((byte) (myBoolean ? 1 : 0)); //if myBoolean == true, byte == 1 readFromParcel: myBoolean = in.readByte() !=

Pass 2D array to another Activity

我是研究僧i 提交于 2019-11-26 11:35:08
问题 how do i pass 2 denominational array object as a parameter to another activity how to get two dimensional array string value in another activity String [][]str; Intent l = new Intent(context,AgAppMenu.class); l.putExtra(\"msg\",str); l.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(l); another Activity class String[][] xmlRespone2; xmlRespone2 = getIntent().getExtras().getString(\"msg\"); 回答1: You can use putSerializable. Arrays are serializable. To store: bundle

How to pass ArrayList of Objects from one to another activity using Intent in android?

你说的曾经没有我的故事 提交于 2019-11-26 11:22:20
I have the following in code in my onClick() method as List<Question> mQuestionsList = QuestionBank.getQuestions(); Now I have the intent after this line, as follows : Intent resultIntent = new Intent(this, ResultActivity.class); resultIntent.putParcelableArrayListExtra("QuestionsExtra", (ArrayList<? extends Parcelable>) mQuestionsList); startActivity(resultIntent); I don't know how to pass this question lists in the intent from one activity to another activity My Question class public class Question { private int[] operands; private int[] choices; private int userAnswerIndex; public Question

Android Class Parcelable with ArrayList

こ雲淡風輕ζ 提交于 2019-11-26 10:36:02
问题 I have an android project where I have a class. In that class is an ArrayList<Choices> . I will be getting some XML, parsing it out, then making objects out of it which I will be passing to another activity. I\'m choosing Parcelable for this. Is Parcelable a good choice? Am I doing everything correctly? I\'m not familiar really with Parcelable. My ArrayList is of another class that I made within this class. Will it properly pass that ArrayList of objects to the Parcel with it not extending

Parcelable and inheritance in Android

心已入冬 提交于 2019-11-26 10:26:02
问题 I got an implementation of Parcelable working for a single class that involves no inheritance. I have problems figuring out the best way to implement the interface when it come to inheritance. Let\'s say I got this : public abstract class A { private int a; protected A(int a) { this.a = a; } } public class B extends A { private int b; public B(int a, int b) { super(a); this.b = b; } } Question is, which is the recommended way to implement the Parcelable interface for B (in A? in both of them?

Problem unmarshalling parcelables

被刻印的时光 ゝ 提交于 2019-11-26 07:30:27
问题 I\'ve got a few classes that implement Parcelable and some of these classes contain each other as properties. I\'m marshalling the classes into a Parcel to pass them between activities. Marshalling them TO the Parcel works fine, but when I try to unmarshall them I get the following error: ... AndroidRuntime E Caused by: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: schemas.Arrivals.LocationType AndroidRuntime E at android.os.Parcel.readParcelable(Parcel.java

Is using Serializable in Android bad?

老子叫甜甜 提交于 2019-11-26 06:20:51
问题 I\'ve been reading a lot of posts and articles extolling the speed of Parcelable over Serializable. I\'ve been using both for a while to pass data between Activities through Intents, and have yet to notice any speed difference when switching between the two. The typical amount of data I have to transfer is 5 to 15 nested objects with 2 to 5 fields each. Since I have about 30 classes which must be transferable, implementing Parcelable requires a lot of boilerplate code that adds maintenance

how to properly implement Parcelable with an ArrayList<Parcelable>?

我是研究僧i 提交于 2019-11-26 05:18:42
问题 I am having trouble making my class Parcelable . The trouble is, I am trying to write to the parcel a member in the class which is an ArrayList<Parcelable> object. The ArrayList is Serializable , and the objects ( ZigBeeDev ) in the list are Parcelable . Here is the relevant code: package com.gnychis.coexisyst; import java.util.ArrayList; import java.util.Iterator; import android.os.Parcel; import android.os.Parcelable; public class ZigBeeNetwork implements Parcelable { public String _mac; //

Read & writing arrays of Parcelable objects

流过昼夜 提交于 2019-11-26 04:38:06
问题 I have following class which reads and writes an array of objects from/to a parcel: class ClassABC extends Parcelable { MyClass[] mObjList; private void readFromParcel(Parcel in) { mObjList = (MyClass[]) in.readParcelableArray( com.myApp.MyClass.class.getClassLoader())); } public void writeToParcel(Parcel out, int arg1) { out.writeParcelableArray(mObjList, 0); } private ClassABC(Parcel in) { readFromParcel(in); } public int describeContents() { return 0; } public static final Parcelable