android-bundle

Store and retrieve array list in Bundle in Android

本小妞迷上赌 提交于 2019-12-22 03:47:03
问题 How do I store and retrieve an array list of values in a Bundle in Android? Any examples? 回答1: Lets take if you array list has strings in it. ArrayList<String> al = new ArrayList<String>(); al.add("test1"); al.add("test2"); al.add("test3"); Now you can put it into bundle as follows: Bundle value= new Bundle(); value.putStringArrayList("temp1", al); If you have your own object type instead of "String" in ArrayList then you need to serialize that ArrayList object. 回答2: Serialize your arraylist

Store and retrieve array list in Bundle in Android

﹥>﹥吖頭↗ 提交于 2019-12-22 03:44:10
问题 How do I store and retrieve an array list of values in a Bundle in Android? Any examples? 回答1: Lets take if you array list has strings in it. ArrayList<String> al = new ArrayList<String>(); al.add("test1"); al.add("test2"); al.add("test3"); Now you can put it into bundle as follows: Bundle value= new Bundle(); value.putStringArrayList("temp1", al); If you have your own object type instead of "String" in ArrayList then you need to serialize that ArrayList object. 回答2: Serialize your arraylist

Android Studio: Passing multiple values using intent PROVIDES ONLY 1 VALUE?

狂风中的少年 提交于 2019-12-22 00:13:00
问题 I am trying to make a quiz where users choose an answer in each activity, and the final page provides an answer based on the chosen options. Therefore, I want to pass these values to the final activity, but only the last chosen value seems to show. First Activity: public class Quiz extends Activity { Button btn; RadioGroup rg; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.quiz); btn = (Button) findViewById(R.id

Can't receive Intent.extras() from Camera after making a photo

旧时模样 提交于 2019-12-21 17:56:23
问题 I found it's a common problem with capturing photo and receiving full size photo instead of thumbnail (according to: http://developer.android.com/training/camera/photobasics.html ). Taking photo and receiving thumbnail is easy, but rest of tutorial seems to be uncomplete and not working. Anyone resolved it in easy way? public class TakePhoto extends Activity{ static final int REQUEST_IMAGE_CAPTURE = 1; static final int REQUEST_TAKE_PHOTO = 1; private String mCurrentPhotoPath; private

Android App Bundle build error: reserved file

故事扮演 提交于 2019-12-18 15:29:36
问题 The new app publishing format, the Android App Bundle, is an improved way to package your app. The Android App Bundle lets you more easily deliver a great experience in a smaller app size, allowing for the huge variety of Android devices available today. You don’t need to refactor your code to start benefiting from a smaller app. I'm getting this error trying to build my app Android Bundle: File 'root/AndroidManifest.xml' uses reserved file or directory name 'AndroidManifest.xml'. APK

Android save state on orientation change

感情迁移 提交于 2019-12-17 17:29:12
问题 I've got an Android application which maintains state regarding distance traveled, time elapsed, etc. This state I can conveniently store in an object and store a reference to that object in the Bundle when Android calls onDestroy() when the user changes the screen orientation, then restore the state in onCreate(Bundle savedBundle). However, I also have some state in the Buttons and EditText objects on the screen that I want to persist through screen orientations. For example, in onStart

What is a “bundle” in an Android application

你。 提交于 2019-12-16 22:41:29
问题 What is a bundle in an Android application? When to use it? 回答1: Bundles are generally used for passing data between various Android activities. It depends on you what type of values you want to pass, but bundles can hold all types of values and pass them to the new activity. You can use it like this: Intent intent = new... Intent(getApplicationContext(), SecondActivity.class); intent.putExtra("myKey", AnyValue); startActivity(intent); You can get the passed values by doing: Bundle extras =

Update Fragment UI with data passed from Activity

纵然是瞬间 提交于 2019-12-13 16:24:18
问题 My Requirement : My MainActivity receives data from other app. MainActivity is listed as shareable . Now, I need to pass this data to a fragment in MainActivity and update the fragment's textview . In MainActivity.java : here I'm handling the received data (which is a URL) in handleSendText method. if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type)) { handleSendText(intent); // Handle text being sent } } } In handleSendText , I'm trying to create a bundle

RuntimeException: Parcel android.os.Parcel: Unmarshalling unknown type code when using android bundle

蓝咒 提交于 2019-12-13 14:22:14
问题 I am getting the below error message: java.lang.RuntimeException: Parcel android.os.Parcel@41141190: Unmarshalling unknown type code 7602286 at offset 16 at android.os.Parcel.readValue(Parcel.java:1921) at android.os.Parcel.readMapInternal(Parcel.java:2094) at android.os.Bundle.unparcel(Bundle.java:223) at android.os.Bundle.getFloat(Bundle.java:981) I am sending an object as a message using WiFi direct. Hence I am converting the object into byte array while sending and reversing the

.getExtras()' on a null object reference

微笑、不失礼 提交于 2019-12-12 03:17:20
问题 I am trying to pass a few values between my activities to make a game work. However, the new activity after passing the information always returns null when I try to .getExtras(). Any thoughts? Code: package name.zerosum; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.RadioButton; import android.widget.Spinner; import android.support.v7.app