Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在没有新意图的情况下清除活动堆栈_Android_Twitter4j - Fatal编程技术网

Android 如何在没有新意图的情况下清除活动堆栈

Android 如何在没有新意图的情况下清除活动堆栈,android,twitter4j,Android,Twitter4j,让我详细说明这个问题。我在应用程序中使用了twitter4j。它运行良好,您知道意图。ACTION\u VIEW正在调用活动中的onNewIntent方法 我满足于这样的回调: protected void onNewIntent(Intent intent) { super.onNewIntent(intent); final Uri uri = intent.getData(); if (uri != null && uri.getScheme().e

让我详细说明这个问题。我在应用程序中使用了
twitter4j
。它运行良好,您知道
意图。ACTION\u VIEW
正在调用活动中的
onNewIntent
方法

我满足于这样的回调:

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);
    }
}
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);
在我按下后退按钮之前,一切都很好。当我按下时,活动返回包含授权页面的网页

是否有任何方法可以清除活动堆栈?我不想将相同的意图称为重启,也不确定有什么不同的出路

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

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

您能提供一些建议吗?

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

你用的是像

Intent webIntent = new Intent(Intent.ACTION_VIEW,
                Uri.parse(token.getAuthorizationURL()));
webIntent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);

更新了我的答案,那面旗怎么了?顺便说一句谢谢。我想问题可能是设置了其他标志。您希望创建新的意图,而不是使用已经在后台运行的浏览器。尝试删除单个\u顶部和\u背景。然后,您可以一次将它们添加回一个,以确定是哪一个导致了问题。