Android 使用api进行身份验证后,应用程序被重新启动,但意图没有数据

Android 使用api进行身份验证后,应用程序被重新启动,但意图没有数据,android,oauth-2.0,stackexchange-api,Android,Oauth 2.0,Stackexchange Api,我正在尝试使用stackexchange api构建一个应用程序,用户在使用stackoverflow.com对其进行自我验证后,将能够使用该应用程序。但我遇到的问题是,在完成身份验证后,当应用程序重新打开时,我正在onResume()中查找意图中的数据,所以它为null,但应该包含一个带有访问令牌的回调url。当我打开url时,我将其传递给intent,以便在浏览器中进行身份验证,因此与回调url访问相关联,但在应用程序中,我得到了null 维持性 显示 在认证后得到的响应url之后: htt

我正在尝试使用stackexchange api构建一个应用程序,用户在使用stackoverflow.com对其进行自我验证后,将能够使用该应用程序。但我遇到的问题是,在完成身份验证后,当应用程序重新打开时,我正在onResume()中查找意图中的数据,所以它为null,但应该包含一个带有访问令牌的回调url。当我打开url时,我将其传递给intent,以便在浏览器中进行身份验证,因此与回调url访问相关联,但在应用程序中,我得到了null

维持性 显示 在认证后得到的响应url之后:

https://stackoverflow.com/oauth/login_success#access_token=nwIxeGi73Bf0rA9Ij4iwcQ))&expires=86400

我不太会编写Android代码。但是,问题代码使用的是
getQueryParameter()
,但是SE API在散列(片段)中发送令牌。这意味着您应该使用类似于
getFragment()
的东西来检索它。好的,我会更改它,但这里的问题是
getIntent()。getData()
返回null,所以代码永远不会到达
getQueryParameter()
。我没有编写太多Android代码。但是,问题代码使用的是
getQueryParameter()
,但是SE API在散列(片段)中发送令牌。这意味着您应该使用类似于
getFragment()
的东西来检索它。好的,我会更改它,但这里的问题是
getIntent()。getData()
返回null,所以代码永远不会到达
getQueryParameter()
...
 <activity android:name=".MainActivity"
            android:launchMode="singleTop">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data
                    android:host="stackoverflow.com"
                    android:pathPrefix="/oauth/login_success"
                    android:scheme="https" />
            </intent-filter>
        </activity>
...

 https://stackoverflow.com/oauth/dialog?client_id=14910&scope=read_inbox&redirect_uri=https%3A%2F%2Fstackoverflow.com%2Foauth%2Flogin_success
https://stackoverflow.com/oauth/login_success#access_token=nwIxeGi73Bf0rA9Ij4iwcQ))&expires=86400