3

让我用细节来澄清这个问题。我twitter4j在我的应用程序中使用。它运行良好,您知道Intent.ACTION_VIEW正在回调onNewIntentActivity 中的方法。

我很满意这样的回调:

protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    final Uri uri = intent.getData();
    if (uri != null && uri.getScheme().equals(Constants.OAUTH_CALLBACK_SCHEME)) {
        Log.d("TAG", "Twitter callback -> New Intent");
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
        new RetrieveAccessTokenTask(this,consumer, provider, prefs). execute(uri);
    }
}

一切都很好,直到我按下后退按钮。当我按下活动返回包含授权页面的网页。

有什么办法可以清除 Activity 堆栈 onNewIntent?我不想将相同的 Intent 称为重新启动,并且不确定是否有任何不同的出路。

更新:我这样调用身份验证页面:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_FROM_BACKGROUND);

你能给点建议吗?

4

1 回答 1

3

您还没有包含在浏览器中打开身份验证页面的代码。调用浏览器视图时设置了哪些标志?我认为这就是你的问题所在。

您是否使用类似...

Intent webIntent = new Intent(Intent.ACTION_VIEW,
                Uri.parse(token.getAuthorizationURL()));
webIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
于 2012-08-09T09:11:06.830 回答