Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Definition of Android Bundle

Tags:

android

bundle

I am new to Android. Can you tell me what is a Bundle and how they are used in android?

like image 570
salman khalid Avatar asked Oct 24 '11 12:10

salman khalid


People also ask

What is the bundle of android?

Android Bundles are generally used for passing data from one activity to another. Basically here concept of key-value pair is used where the data that one wants to pass is the value of the map, which can be later retrieved by using the key.

What is bundle in mobile?

An Android App Bundle is a publishing format that includes all your app's compiled code and resources, and defers APK generation and signing to Google Play.

What is the difference between Android App Bundle and APK?

App bundles are publishing format, whereas APK (Android application Package) is the packaging format which eventually will be installed on device. Google uses app bundle to generate and serve optimized APKs for each user's device configuration, so they download only the code and resources they need to run your app.

Is bundle a class in android?

The Bundle class is highly optimized for marshalling and unmarshalling using parcels. In some cases, you may need a mechanism to send composite or complex objects across activities. In such cases, the custom class should implement Parcelable, and provide the appropriate writeToParcel(android.


2 Answers

Bundle generally use for passing data between various Activities. It depends on you what type of values you want to pass but bundle can hold all types of values and pass to the new activity.

You can use it like ...

Intent intent = new
Intent(getApplicationContext(),SecondActivity.class);
intent.putExtra("myKey",AnyValue);  
startActivity(intent);

Now you can get the passed values by...

Bundle extras = intent.getExtras(); 
String tmp = extras.getString("myKey");

you can also find more info on android-using-bundle-for-sharing-variables and Passing-Bundles-Around-Activities

Copy from Here.

like image 91
Chirag Avatar answered Sep 23 '22 18:09

Chirag


Read this:

http://developer.android.com/reference/android/os/Bundle.html

It can be used to pass data between different Activity's

like image 34
nhaarman Avatar answered Sep 19 '22 18:09

nhaarman