mobicontrol.android.Bundle

This class represents an Android bundle.

Bundle

Since:
  • Version 1.8 (API level 9)

Methods

getBoolean(key)nullable {boolean}

Get boolean value for the given key.
Parameters:
Name Type Description
key string The key.
Returns:
boolean - Value for the key or null if no boolean mapping exists for the given key.
Since:
  • Version 1.8 (API level 9)

getByte(key)nullable {number}

Get byte value for the given key.
Parameters:
Name Type Description
key string The key.
Returns:
number - Value for the key or null if no byte mapping exists for the given key.
Since:
  • Version 1.8 (API level 9)

getChar(key)nullable {string}

Get char value for the given key.
Parameters:
Name Type Description
key string The key.
Returns:
string - Value for the key or null if no char mapping exists for the given key.
Since:
  • Version 1.8 (API level 9)

getDouble(key)nullable {number}

Get double value for the given key.
Parameters:
Name Type Description
key string The key.
Returns:
number - Value for the key or null if no double mapping exists for the given key.
Since:
  • Version 1.8 (API level 9)

getFloat(key)nullable {number}

Get float value for the given key.
Parameters:
Name Type Description
key string The key.
Returns:
number - Value for the key or null if no float mapping exists for the given key.
Since:
  • Version 1.8 (API level 9)

getInteger(key)nullable {number}

Get integer value for the given key.
Parameters:
Name Type Description
key string The key.
Returns:
number - Value for the key or null if no integer mapping exists for the given key.
Since:
  • Version 1.8 (API level 9)

getIntegerArray(key)nullable {Array.<number>}

Get integer array value for the given key.
Parameters:
Name Type Description
key string The key.
Returns:
Array.<number> - Value for the key or null if no integer array mapping exists for the given key.
Since:
  • Version 1.8 (API level 9)

getLong(key)nullable {number}

Get long value for the given key.
Parameters:
Name Type Description
key string The key.
Returns:
number - Value for the key or null if no long mapping exists for the given key.
Since:
  • Version 1.8 (API level 9)

getShort(key)nullable {number}

Get short value for the given key.
Parameters:
Name Type Description
key string The key.
Returns:
number - Value for the key or null if no short mapping exists for the given key.
Since:
  • Version 1.8 (API level 9)

getString(key)nullable {string}

Get string value for the given key.
Parameters:
Name Type Description
key string The key.
Returns:
string - Value for the key or null if no string mapping exists for the given key.
Since:
  • Version 1.8 (API level 9)
Example
var extras = mobicontrol.android.createBundle().
    withString("stringKey", "Welcome");

mobicontrol.log.info(extras.getString("stringKey"));

getStringArray(key)nullable {Array.<string>}

Get string array value for the given key.
Parameters:
Name Type Description
key string The key.
Returns:
Array.<string> - Value for the key or null if no string array mapping exists for the given key.
Since:
  • Version 1.8 (API level 9)

getUri(key)nullable {mobicontrol.android.Uri}

Get URI value for the given key.
Parameters:
Name Type Description
key string The key.
Returns:
mobicontrol.android.Uri - Value for the key or null if no URI mapping exists for the given key.
Since:
  • Version 1.8 (API level 9)

withBoolean(key, value) → {mobicontrol.android.Bundle}

Insert a boolean value into the mapping of this bundle.

Any existing value for the given key is replaced with the new value.
Parameters:
Name Type Description
key string The key.
value boolean The value.
Returns:
mobicontrol.android.Bundle - This bundle.
Since:
  • Version 1.8 (API level 9)
Example
// Open the Calendar app, adding "John Doe Vacation" all-day event on October 20, 2025
const startTime = new Date("2025-10-20T11:00:00").getTime();
var extras = mobicontrol.android.createBundle().
    withString("title", "John Doe Vacation").
    withBoolean("allDay", true);
var intent = mobicontrol.android.createIntent().
    withData("content://com.android.calendar/events").
    withAction("android.intent.action.INSERT").
    withExtras(extras);
mobicontrol.android.startActivity(intent);

withByte(key, value) → {mobicontrol.android.Bundle}

Insert a byte value into the mapping of this bundle.

Any existing value for the given key is replaced with the new value.
Parameters:
Name Type Description
key string The key.
value number The value.
Returns:
mobicontrol.android.Bundle - This bundle.
Since:
  • Version 1.8 (API level 9)

withChar(key, value) → {mobicontrol.android.Bundle}

Insert a char value into the mapping of this bundle.

Any existing value for the given key is replaced with the new value.
Parameters:
Name Type Description
key string The key.
value string The value.
Returns:
mobicontrol.android.Bundle - This bundle.
Since:
  • Version 1.8 (API level 9)

withDouble(key, value) → {mobicontrol.android.Bundle}

Insert a double value into the mapping of this bundle.

Any existing value for the given key is replaced with the new value.
Parameters:
Name Type Description
key string The key.
value number The value.
Returns:
mobicontrol.android.Bundle - This bundle.
Since:
  • Version 1.8 (API level 9)

withFloat(key, value) → {mobicontrol.android.Bundle}

Insert a float value into the mapping of this bundle.

Any existing value for the given key is replaced with the new value.
Parameters:
Name Type Description
key string The key.
value number The value.
Returns:
mobicontrol.android.Bundle - This bundle.
Since:
  • Version 1.8 (API level 9)

withInteger(key, value) → {mobicontrol.android.Bundle}

Insert an integer value into the mapping of this bundle.

Any existing value for the given key is replaced with the new value.
Parameters:
Name Type Description
key string The key.
value number The value.
Returns:
mobicontrol.android.Bundle - This bundle.
Since:
  • Version 1.8 (API level 9)

withIntegerArray(key, valuenullable) → {mobicontrol.android.Bundle}

Insert an integer array value into the mapping of this bundle.

Any existing value for the given key is replaced with the new value.
Parameters:
Name Type Attributes Description
key string The key.
value Array.<number> <nullable>
The value.
Returns:
mobicontrol.android.Bundle - This bundle.
Since:
  • Version 1.8 (API level 9)

withLong(key, value) → {mobicontrol.android.Bundle}

Insert a long value into the mapping of this bundle.

Any existing value for the given key is replaced with the new value.
Parameters:
Name Type Description
key string The key.
value number The value.
Returns:
mobicontrol.android.Bundle - This bundle.
Since:
  • Version 1.8 (API level 9)
Example
// Open the Calendar app, adding "Travel Plan Discussion" event on October 20, 2024, starting at 11AM and ending at 12PM
const startTime = new Date("2024-10-20T11:00:00").getTime();
const endTime = new Date("2024-10-20T12:00:00").getTime();
var extras = mobicontrol.android.createBundle().
    withString("title", "Travel Plan Discussion").
    withString("location", "3rd floor meeting room").
    withLong("beginTime", startTime).
    withLong("endTime", endTime);
var intent = mobicontrol.android.createIntent().
    withData("content://com.android.calendar/events").
    withAction("android.intent.action.INSERT").
    withExtras(extras);
mobicontrol.android.startActivity(intent);

withShort(key, value) → {mobicontrol.android.Bundle}

Insert a short value into the mapping of this bundle.

Any existing value for the given key is replaced with the new value.
Parameters:
Name Type Description
key string The key.
value number The value.
Returns:
mobicontrol.android.Bundle - This bundle.
Since:
  • Version 1.8 (API level 9)

withString(key, value) → {mobicontrol.android.Bundle}

Insert a string value into the mapping of this bundle.

Any existing value for the given key is replaced with the new value.
Parameters:
Name Type Description
key string The key.
value string The value.
Returns:
mobicontrol.android.Bundle - This bundle.
Since:
  • Version 1.8 (API level 9)
Example
// Launch Google quick search, performing a search for "Android intent" keywords
var extras = mobicontrol.android.createBundle().withString("query", "Android intent");
var intent = mobicontrol.android.createIntent().
    withAction("com.google.android.googlequicksearchbox.GOOGLE_SEARCH").
    withExtras(extras);
mobicontrol.android.startActivity(intent);

withStringArray(key, valuenullable) → {mobicontrol.android.Bundle}

Insert a string array value into the mapping of this bundle.

Any existing value for the given key is replaced with the new value.
Parameters:
Name Type Attributes Description
key string The key.
value Array.<string> <nullable>
The value.
Returns:
mobicontrol.android.Bundle - This bundle.
Since:
  • Version 1.8 (API level 9)

withUri(key, valuenullable) → {mobicontrol.android.Bundle}

Insert a URI value into the mapping of this bundle.

Any existing value for the given key is replaced with the new value.
Parameters:
Name Type Attributes Description
key string The key.
value mobicontrol.android.Uri <nullable>
The value.
Returns:
mobicontrol.android.Bundle - This bundle.
Since:
  • Version 1.8 (API level 9)
Example
// Capture image with Android camera and store it in data folder of internal storage
var file = new mobicontrol.io.File(mobicontrol.storage.internal.dataDirectory + "/target.jpg");
var fileUri = mobicontrol.android.createFileContentUri(file)
var extras = mobicontrol.android.createBundle().withUri("output", fileUri);
var intent = mobicontrol.android.createIntent().
    withAction("android.media.action.IMAGE_CAPTURE").
    withExtras(extras);
mobicontrol.android.startActivity(intent);