我对活动(Cordova 活动)的 onActivityResult 方法有问题,以下是发生这种情况的情况
- 启动活动1
- StartActivityForResult 命名为 Activity2
- 按主页按钮
- 通过单击应用程序图标重新启动应用程序
我正在调用启动启动活动,然后调用 activity1 但这给了我 onActivityResult 上的 nullpointerException 并且该活动也没有显示视图。
谁能给我解决方案来避免这个错误?
<activity
android:name=".MDLIVEMain"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
android:label="@string/app_name"
android:launchMode="singleTask"
android:taskAffinity=""
android:clearTaskOnLaunch="true"
android:finishOnTaskLaunch="true"
android:excludeFromRecents="true"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:windowSoftInputMode="adjustResize" />
结果部分的开始活动
Intent passcodeIntent = new Intent(getActivity(), PasscodeActivity.class);
passcodeIntent.putExtra("passcode_data_page",passcodeDataPage);
startActivityForResult(passcodeIntent, PASSCODE_RESULT_PAGE);
OnaActivityResult 代码
@Override
protected void onActivityResult(int requestCode, int responseCode, Intent intent) {
CordovaPlugin callback = this.activityResultCallbacks;
try {
Log.d("onActivityResult",requestCode+"-"+responseCode+"");
if (requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == RESULT_OK) {
mConnectionResult = null;
mPlusClient.connect();
}
if (callback != null) {
callback.onActivityResult(requestCode, responseCode, intent);
}
getActivity().runOnUiThread(new Runnable() {
public void run() {
mConnectionProgressDialog.dismiss();
}
});
if (requestCode == PASSCODE_RESULT_PAGE) {
if (responseCode == RESULT_OK) {
activityVisible = true;
this.callbackContext.success(intent.getExtras().getString("passcode_pin"));
} else {
this.callbackContext.success(intent.getExtras().getString("passcode_pin"));
isFromPasscodePage = true;
}
}
}catch (Exception e){
e.printStackTrace();
// finish();
}
}
错误来这里
this.callbackContext.success(intent.getExtras().getString("passcode_pin"));
isFromPasscodePage = true;