I'm using the AppAuth library and trying to open the google website and go back to my activity (baseActivity) that calls a webview. Basically i have a method that makes a call to open a webview page that i cannot put in the "OAuthJava" class, so I created an interface in the BaseActivity class, which I pass to the "OAuthJava" activity that makes the request for appAuth and after giving success uses the interface that is in the other activity to open the method that opens the webview
Error android : IlegalStateException: can not perform this action after onSaveInstance
@EActivity
public abstract class BaseActivity extends AppCompatActivity {
//code
private void test() {
//this builder is to create an intent to open the new activity and I pass this interface so that the next //activity can call the method that calls the webview
new OpenAppAuth.Builder()
.context(this)
.listener(new abc())
.build();
}
class abc implements RedirectInterface {
@Override
public void goToWebView() {
gotoScreen();
}
}
private void gotoScreen(String menuItem) {
//code that calls a webview screen
}
}
this class makes the call from the google site using appAuth
public class OAuthJava extends AppCompatActivity {
public static final int OAUTH_RC = 7777;
private RedirectInterface repository; // receives the abc class
@Override
public void onCreate(final Bundle icicle) {
// create the appauth request by opening google
Intent authIntent = authService.getAuthorizationRequestIntent(authRequest);
startActivityForResult(authIntent, OAUTH_RC);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == OAUTH_RC) {
AuthorizationResponse resp = AuthorizationResponse.fromIntent(data);
AuthorizationException ex = AuthorizationException.fromIntent(data);
if (resp != null) {
//success
//after I click on my email enter the "if" that calls goToWebView (interface abc)
repository.goToWebView();
}
}
}
error:
- beginning of crash
2021-04-01 18:52:58.729 9870-9870/com. E/AndroidRuntime: FATAL EXCEPTION: main
Process: com., PID: 9870
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7777, result=-1, data=Intent { (has extras) }} to activity {com./br.o.commons.repository.OAuthJava}: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at android.app.ActivityThread.deliverResults(ActivityThread.java:4423)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4465)
at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at androidx.fragment.app.FragmentManager.checkStateLoss(FragmentManager.java:1832)
at androidx.fragment.app.FragmentManager.enqueueAction(FragmentManager.java:1872)
at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:329)
at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:294)