A value passing through Intent returns null for a while

I pass some values โ€‹โ€‹through Intent, in some case the value passed through it returns null. The value is not null until it is set to intent. Here is the code where I set the intent.

Intent propertyIntent = new Intent(mContext , SomeActivity.class); propertyIntent.putExtra(START_MODE_TAG,MODE_EDIT_RECORDING); propertyIntent.putExtra(ACTIVITY_MODE_TAG, "dm"); propertyIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); propertyIntent.putParcelableArrayListExtra("det_list", detList); mContext.startActivity(propertyIntent); 

Here is the code used to extract intent values

 passedModeName = getIntent().getStringExtra(DMApplication.START_MODE_TAG); 

only a START_MODE_TAG value returns null rest, everything returns correctly. I also tried setting to onNewIntent() . But to no avail.

The constants that I used in it

 public static final String ACTIVITY_MODE_TAG="activity_mode"; public static final String START_MODE_TAG="StartMode"; public static final String MODE_NEW_RECORDING="new"; public static final String MODE_EDIT_RECORDING="edit"; public static final String MODE_REVIEW_RECORDING="review"; public static final String MODE_COPY_RECORDING="copy"; public static final String MODE_LAUNCH_RECORDING="launch"; 
+4
source share
2 answers

You should get additional data as follows.

 Bundle extras = getIntent().getExtras(); selectedGroupId = extras.getString(DMApplication.START_MODE_TAG); 
0
source

Verify that the * DMApplication.START_MODE_TAG * keys match * START_MODE_TAG * and MODE_EDIT_RECORDING are not null.

0
source

Source: https://habr.com/ru/post/1491370/


All Articles