0

I started an sub activity for results and it retuen a bundle contains some data to the parent activity.

the problem is, in the parent activtiy in the onActivityResult() method, i checked if there is a bundle returned from the sub activity with a specific name

bunConnAssets

but the if-condition in the switch-case suggests that there is no bundle with the given name

please let me know where is my error.

in subActivity:

if (this.mqttSettingsDB != null) {
        Log.d(TAG, "this.mqttSettingsDB is not null.");

        int[] id = this.mqttSettingsDB.getIDs();
        Bundle bunConnAssets = new Bundle();
        Intent intConnAssets = new Intent();
        ....
        ....
        ....

        intConnAssets.putExtras(bunConnAssets);
        setResult(RESULT_OK, intConnAssets);

MainActivity:

switch (requestCode) {
    case REQUEST_CODE:
        if (resultCode == MainActivityA.RESULT_OK) {
            if (data != null) {
                if (data.hasExtra("bunConnAssets")) {
                    Log.d(TAG, "Bundle exists");
                } else {
                    Log.d(TAG, "Bundle does not exist");
                }
            }
        } else {
            Log.d(TAG, "resultCode != RESULT_OK");
        }

LogCat:

02-03 12:36:38.737: W/SettingsActivity(12659): @finish().
02-03 12:36:38.737: D/SettingsActivity(12659): this.mqttSettingsDB is not null.
02-03 12:36:38.957: W/MQTT_Settings_Frag(12659): @onPause().
rmaik
  • 1,076
  • 3
  • 15
  • 48

1 Answers1

0

You can get the Bundle using below code

Bundle extras = data.getExtras();
if (extras!=null) {
    Log.d(TAG, "Bundle exists");
     } else {
     Log.d(TAG, "Bundle does not exist");   
   }
Ramesh
  • 526
  • 3
  • 14