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背景。然后,您可以一次将它们添加回一个,以确定是哪一个导致了问题。