What is android bundle object

Building your first app bundle

Android App Bundle is the new and official publishing format for Android applications.

This article is available as a video and linked at the end of the post.

With the Android App Bundle we created a format that unlocks, amongst other things, shipping smaller apps to your users. Smaller apps are more likely to be installed and less likely to be uninstalled when disk space gets tight.

In this post we’ll take a closer look at how to build your first app bundle, how you can upload it using the Play Console and dive into some configuration options.

Getting started doesn’t require any changes to your existing codebase.

All you’ll need to do is create an Android App Bundle, using the command line or Android Studio.

Building on the command line

On the command line, you’ll run one of the bundle tasks like this:

Then locate the bundle in your application’s build directory. The default location is app/build/outputs/bundle/release .

This bundle needs to be signed. When using jarsigner , this is how you sign the bundle:

Once the variables are replaced with actual values and the keystore password is entered, the bundle will be signed and ready for upload.

Building in Android Studio

In Android Studio, select “Build => Generate Signed Bundle / APK” and follow the dialog.

Whether you use the command line or Android Studio, the process will leave you with a built and signed release bundle that’s ready for upload to the Play Store.

Uploading through the Play Console

To upload your app bundle to the Play Store, create a new release on a chosen release track. You can drag and drop the bundle into the “App bundles and APKs” section or use the Google Play Developer API.

Once the Bundle is uploaded, the Play Store can optimize the APKs it delivers to users’ devices based on their configuration. This in turn reduces download and installation size.

Exploring your Android App Bundle

To take a look at how the Play Store ships your app to a user’s device, you can click on the “Details” button at the end of the bundle’s row.

In the details screen you already see a lot of information on your app bundle such as version code, minSdk level, target SDK, required features, permissions, screen layouts, localizations and much more.

And you also can download signed APKs for your app, to see exactly what the Play Store delivers to a specific device. To navigate there, click on “Explore Bundle” and then open the “Downloads” tab.

You can either select a specific device or apply one or more of the many filters from the “Add filter” tab.

Download the app bundle and install locally

In the app bundle explorer, at the end of your screen, there is a “Download” button which provides a zip file, containing several APK, which are tailored to the specific device in question.

After you download and unzip the file, the containing APK can be installed on a local emulator or device by using `adb install — multiple *.apk` from the containing directory.

While each apk in this set is relevant to guarantee correct execution of your app, I want to point out that the base.apk always has to be installed on a device in order to provide your app’s core functionality. Next to code and resources the base module also contains the merged AndroidManifest and shared dependencies for the entire application.

Each feature module or configuration split provides its own resources and can contain code, but the base module is what ties it all together.

Disabling optimizations

You can disable the optimization in each module’s build.gradle file. All you have to do is edit the language , density or abi property and set enableSplit to false . This will tell the build system that it should not optimize this specific dimension.

Unless you have a good reason to, I recommend not touching this section as setting enableSplit to false can dramatically increase the on-device installation size of your app.

There could be exceptions, such as when your app has its own language selector built in and you want to have all potential languages available for selection at all times. But even then, using the Android App Bundle provides you with ways to load features on demand instead. This could be used to avoid to pre-install parts of your app that only a subset of users might need.

And since we enable you to download and install features in a programmatic way, we provide an unbundled API that you can use. It is part of the PlayCore library and is covered as part of the next post and this video in our Modern Android Development Skills series.

Источник

Bundle in Android with Example

It is known that Intents are used in Android to pass to the data from one activity to another. But there is one another way, that can be used to pass the data from one activity to another in a better way and less code space ie by using Bundles in 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. Bundles are used with intent and values are sent and retrieved in the same fashion, as it is done in the case of Intent. It depends on the user what type of values the user wants to pass, but bundles can hold all types of values (int, String, boolean, char) and pass them to the new activity.

Читайте также:  Лайм тв для андроид приставки

The following are the major types that are passed/retrieved to/from a Bundle:

putInt(String key, int value), getInt(String key, int value)

putString(String key, String value), getString(String key, String value)

putStringArray(String key, String[] value), getStringArray(String key, String[] value)

putChar(String key, char value), getChar(String key, char value)

putBoolean(String key, boolean value), getBoolean(String key, boolean value)

Using the Bundle in the Android App

The bundle is always used with Intent in Android. Now to use Bundle writes the below code in the MainActivity.

Источник

Bundle Class

Definition

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

A mapping from String keys to various Parcelable values.

Remarks

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Constructors

Constructs a new, empty Bundle.

Constructs a new, empty Bundle.

Constructs a new, empty Bundle.

Constructs a new, empty Bundle.

Constructs a new, empty Bundle.

Properties

Returns the runtime class of this Object .

(Inherited from Object) ClassLoader

Return the ClassLoader currently associated with this Bundle.

An unmodifiable Bundle that is always #isEmpty() empty .

The handle to the underlying Android instance.

(Inherited from Object) HasFileDescriptors

Reports whether the bundle contains any parcelled file descriptors.

Returns true if the mapping of this Bundle is empty, false otherwise.

JniIdentityHashCode (Inherited from Object) JniPeerMembers PeerReference (Inherited from Object) ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from BaseBundle) ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from BaseBundle)

Methods

Removes all elements from the mapping of this Bundle.

Clones the current Bundle.

Returns true if the given key is contained in the mapping of this Bundle.

Make a deep copy of the given bundle.

Report the nature of this Parcelable’s contents

Dispose() (Inherited from Object) Dispose(Boolean) (Inherited from Object) Equals(Object)

Indicates whether some other object is «equal to» this one.

(Inherited from Object) Get(String)

Returns the entry with the given key as an object.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or false if no mapping of the desired type exists for the given key.

Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or (byte) 0 if no mapping of the desired type exists for the given key.

Returns the value associated with the given key, or (byte) 0 if no mapping of the desired type exists for the given key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or (char) 0 if no mapping of the desired type exists for the given key.

Returns the value associated with the given key, or (char) 0 if no mapping of the desired type exists for the given key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Читайте также:  Angry bird seasons android

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or 0.0 if no mapping of the desired type exists for the given key.

Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or 0.

Returns the value associated with the given key, or 0.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns a hash code value for the object.

(Inherited from Object) GetInt(String)

Returns the value associated with the given key, or 0 if no mapping of the desired type exists for the given key.

Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or 0L if no mapping of the desired type exists for the given key.

Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or (short) 0 if no mapping of the desired type exists for the given key.

Returns the value associated with the given key, or (short) 0 if no mapping of the desired type exists for the given key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)

Читайте также:  Android как сетевая папка windows
KeySet()

Returns a Set containing the Strings used as keys in this Bundle.

Wakes up a single thread that is waiting on this object’s monitor.

(Inherited from Object) NotifyAll()

Wakes up all threads that are waiting on this object’s monitor.

(Inherited from Object) PutAll(Bundle)

Inserts all mappings from the given Bundle into this Bundle.

Inserts all mappings from the given PersistableBundle into this BaseBundle.

(Inherited from BaseBundle) PutBinder(String, IBinder)

Inserts an IBinder value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a Boolean value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a boolean array value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a Bundle value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a byte value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a byte array value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a char value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a char array value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a CharSequence value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a CharSequence value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a CharSequence array value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a CharSequence array value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts an ArrayList value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a double value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a double array value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a float value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a float array value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts an int value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts an int array value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts an ArrayList value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a long value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a long array value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a Parcelable value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts an array of Parcelable values into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a List of Parcelable values into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a Serializable value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a short value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a short array value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a Size value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a SizeF value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a SparceArray of Parcelable values into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a String value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts a String array value into the mapping of this Bundle, replacing any existing value for the given key.

Inserts an ArrayList value into the mapping of this Bundle, replacing any existing value for the given key.

Reads the Parcel contents into this Bundle, typically in order for it to be passed through an IBinder connection.

Removes any entry with the given key from the mapping of this Bundle.

Changes the ClassLoader this Bundle uses when instantiating objects.

Sets the Handle property.

(Inherited from Object) Size()

Returns the number of mappings contained in this Bundle.

Returns a string representation of the object.

(Inherited from Object) UnregisterFromRuntime() (Inherited from Object) Wait()

Causes the current thread to wait until another thread invokes the java.lang.Object#notify() method or the java.lang.Object#notifyAll() method for this object.

(Inherited from Object) Wait(Int64)

Causes the current thread to wait until another thread invokes the java.lang.Object#notify() method or the java.lang.Object#notifyAll() method for this object.

(Inherited from Object) Wait(Int64, Int32)

Causes the current thread to wait until another thread invokes the java.lang.Object#notify() method or the java.lang.Object#notifyAll() method for this object.

(Inherited from Object) WriteToParcel(Parcel, ParcelableWriteFlags)

Writes the Bundle contents to a Parcel, typically in order for it to be passed through an IBinder connection.

Explicit Interface Implementations

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

Performs an Android runtime-checked type conversion.

Источник

Оцените статью