To receive a single data: int value = getIntent().getExtras().getInt('KEY_INTEGER_VALUE') Īs well as, you can receive multiple data/objects using Bundle: Bundle bundle = getIntent().getExtras() Intent.putExtra('KEY_BUNDLE_VALUE', bundle) Intent.putExtra('KEY_STRING_VALUE', 'String data') Īlso, you can use Bundle to send multiple data via Intent as following: Intent intent = new Intent(FirstActivity.this, SecondActivity.class) īundle.putDouble('KEY_DOUBLE_VALUE', 40.5) īundle.putBoolean('KEY_BOOLEAN_VALUE', true) īundle.putString('KEY_STRING_VALUE', 'String data') Intent.putExtra('KEY_BOOLEAN_VALUE', true) Intent.putExtra('KEY_DOUBLE_VALUE', 40.5)
To send primitive or String data from one Activity to another Activity: Intent intent = new Intent(FirstActivity.this, SecondActivity.class) boolean, byte, char, short, int, long, float and double ), string or user-defined objects, then we can send it as intent extras. For example, if the data is primitive type ( e.g. Basically, we can pass data depending on the data-types. The most common way to send data is using Intent. There are several ways to do it which is summarizing below: 1.
Activity to Activity, Activity to Fragment, Fragment to Fragment) can be various which is depending on the data-types. In the Android projects, data-passing from here to there (e.g.