【发布时间】:2013-03-22 11:06:46
【问题描述】:
我已经坚持了好几个小时了,因为它之前工作正常,但突然停止以按预期运行。我真的不知道如何以及为什么,因为我一直在重新检查过程中的每一行代码,却看不出有什么问题,所以我向你们寻求帮助。
好的。所以我有一个LoginScreen 活动,带有一个按钮,在点击时开始一个新的Intent.ACTION_VIEW。这将在浏览器中启动 OAUTH 进程,并将 ApiManager.OAUTH_CALLBACK_URI 设置为 stjapp://oauthresponse。
这是我在此活动中的AndroidManifest.xml 部分:
<activity
android:name=".LoginScreen"
android:label="@string/application"
android:launchMode="singleTask">
<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:scheme="stjapp" android:host="oauthresponse" />
</intent-filter>
</activity>
我如何在我的活动中启动Intent.ACTION_VIEW:
private View.OnClickListener loginHandler = new View.OnClickListener() {
public void onClick(View v) {
OAuthClientRequest request = null;
try {
request = OAuthClientRequest
.authorizationLocation(ApiManager.OAUTH_AUTHORIZE)
.setClientId(ApiManager.CLIENT_ID).setRedirectURI(ApiManager.OAUTH_CALLBACK_URI)
.buildQueryMessage();
}
catch (OAuthSystemException e) { e.printStackTrace(); }
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(request.getLocationUri() + "&response_type=code"));
startActivity(intent);
}
};
这是浏览器中发生的屏幕截图:
在那里,我应该回到我的 LoginScreen 活动并在 onNewIntent 方法中处理 code 查询参数,但是......是的,事情不再按预期工作了。
任何帮助表示赞赏。
【问题讨论】:
-
使用 Android 内置浏览器打开链接后一切正常。开始觉得我必须使用内部的
WebView,而不是让这部分 OAuth 进程在外面。有什么想法吗?
标签: android android-intent android-manifest