有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

错误:安卓 java。lang.RuntimeException:传递结果ResultInfo失败

我正在使用AppAuth库,试图打开google网站,然后返回我的活动(baseActivity),它调用webview。 基本上,我有一个方法,可以调用打开一个webview页面,我不能将其放入“OAuthJava”类中,所以我在BaseActivity类中创建了一个接口,我将其传递给请求appAuth的“OAuthJava”活动,并在成功后使用其他活动中的接口打开打开webview的方法

错误安卓:IlegalStateException:在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
    }

}

此类使用appAuth从google站点进行调用

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();

      }
}
}

错误:

- 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 安卓.app.ActivityThread.deliverResults(ActivityThread.java:4423)
        at 安卓.app.ActivityThread.handleSendResult(ActivityThread.java:4465)
        at 安卓.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
        at 安卓.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at 安卓.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at 安卓.app.ActivityThread$H.handleMessage(ActivityThread.java:1831)
        at 安卓.os.Handler.dispatchMessage(Handler.java:106)
        at 安卓.os.Looper.loop(Looper.java:201)
        at 安卓.app.ActivityThread.main(ActivityThread.java:6810)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.安卓.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.安卓.internal.os.ZygoteInit.main(ZygoteInit.java:873)
     Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
        at 安卓x.fragment.app.FragmentManager.checkStateLoss(FragmentManager.java:1832)
        at 安卓x.fragment.app.FragmentManager.enqueueAction(FragmentManager.java:1872)
        at 安卓x.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:329)
        at 安卓x.fragment.app.BackStackRecord.commit(BackStackRecord.java:294)

共 (0) 个答案