回去后打电话Intent.ACTION_VIEW在安卓 [英] Go back after call Intent.ACTION_VIEW in android
问题描述
我的应用程序有3个活动A,B,C活性A调用B.在B,我叫Intent.ACTION_VIEW做认证与Twitter如下:
My app has 3 activity A, B, C. Activity A calls B. In B, I call Intent.ACTION_VIEW to do authentication with Twitter as below:
public static void DoAuthen(Context context, String CallBackUrl) throws OAuthMessageSignerException, OAuthNotAuthorizedException,
OAuthExpectationFailedException, OAuthCommunicationException {
httpOauthConsumer = new CommonsHttpOAuthConsumer(context.getString(R.string.Twitter_ConsumerKey), context
.getString(R.string.Twitter_ConsumerSecret));
httpOauthprovider = new DefaultOAuthProvider("http://twitter.com/oauth/request_token", "http://twitter.com/oauth/access_token",
"http://twitter.com/oauth/authorize");
String authUrl = httpOauthprovider.retrieveRequestToken(httpOauthConsumer, CallBackUrl);
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl)));
}
验证后,我的应用程序被称为回活动B.这里B调用C. 现在,如果我preSS后退按钮,它就会定位到浏览器(它使用之前与Twitter进行身份验证),而不是B,然后到A. 我该如何解决此问题?
After authentication, My App is called back at activity B. Here B calls C. Now if I press Back button, it will navigate to browser (which used to authenticate with Twitter before) rather than to B and then to A. How can I resolve this?
推荐答案
请参阅的任务和返回堆栈中的Android 。您可以使用两个任务在你的应用程序 - 在第一次你做你的生意,在第二 - 授权。你开始意图标志 FLAG_ACTIVITY_NEW_TASK 和使用参数的安卓clearTaskOnLaunch 。祝你好运!
Please refer to Tasks and Back stack in android. You can use two tasks in your application - in first one you do your business, in second - authorization. You start authorization with intent flag FLAG_ACTIVITY_NEW_TASK and use parameter android:clearTaskOnLaunch. Good luck!
这篇关于回去后打电话Intent.ACTION_VIEW在安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!