Working environment (bold blue for special attention)
1, System environment: Win7 Ultimate SP1, Android Studio 3.2
Oddly enough, today when a Bundle is used to pass values between activities, it is not possible to get the value passed in. Look at the pass-value code:
1, System environment: Win7 Ultimate SP1, Android Studio 3.2
Oddly enough, today when a Bundle is used to pass values between activities, it is not possible to get the value passed in. Look at the pass-value code:
Bundle bundle = new Bundle();
bundle.putInt(EXAM_CENTER_TYPE, EXAM_CENTER_1);
toActivity(ExamTypeActivity.class, bundle);
protected void toActivity(Class<?> clazz, Bundle bundle) {
Intent intent = new Intent();
intent.setClass(this, clazz);
if (bundle != null) {
intent.putExtras(bundle);
}
startActivity(intent);
}
Value code:
protected Bundle getExtra() {
Intent intent = getIntent();
if (intent != null) {
return getIntent().getExtras();
} else {
return null;
}
}
protected String getExtraString(String key) {
Bundle bundle = getExtra();
if (bundle != null) {
return bundle.getString(key);
} else {
return "";
}
}
protected int getExtraInt(String key) {
String extra = getExtraString(key);
return NumberUtils.getInt(extra);
}
GetExtraaint (EXAM_CENTER_TYPE) cannot get a value. The reason is that the data type passed to PUT must be the same as that of GET. If you put is a string, get is a string. The getExtraint function can be changed to the following function:
protected int getExtraInt(String key) {
Bundle bundle = getExtra();
if (bundle != null) {
return bundle.getInt(key);
} else {
return 0;
}
}
Read More:
- Error receiving broadcast Intent { act=com.supersdk.listen.PayListen_defeat flg=0x10 (has extras)
- The reason and solution of Android intent value not updated
- Android android.intent.category Purpose and use of. Launcher
- Xcode Error: Embedded binary’s bundle identifier is not prefixed with the parent app’s bundle identifier
- The intent solution cannot be updated in onrestart method
- Vue3 uses webpack bundle analyzer to analyze package files
- Not allowed to bind to service Intent [How to Solve]
- curl: (22) The requested URL returned error: 404 Not Found Server does not provide clone.bundle; ig
- Error: Error parsing D:\new_android\Android SDK\system-images\android-25\android-wear\armeabi-v7a\de
- Android Studio | Failed to find target with hash string ‘android-26’ in: D:\Android\sdk
- HDFS and local file transfer and error reporting
- Xftp transfer file error
- Error: transfer of control bypasses initialization of: variable XXX solution
- 107_ Error report and solution of erc20 token transfer
- Quirky error 18: transfer closed with outstanding read data rem
- Failed to load bundle…Unable to resolve module `xxx` from xxx: Module `xx` does not exist
- Error: No such keg: /usr/local/Cellar/node&install nvm&brew installation&Oh my zsh.git installation&git set alias&No bundle URL prese
- Modify the VDI path of VirtualBox on MacOSX, and transfer the virtual machine
- Using AspectJ to transfer the data written to FTP service to MySQL database
- [solution] (transfer) win10 home edition, permanently close the update