在android中调用Intent.ACTION_VIEW之后返回

Ngu*_*inh 5 android android-intent twitter4j twitter-oauth

我的应用程序有3个活动A,B,C.活动A调用B.在B中,我调用Intent.ACTION_VIEW对Twitter进行身份验证,如下所示:

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)));
}
Run Code Online (Sandbox Code Playgroud)

验证后,我的应用程序在活动B回调.这里B调用C.现在,如果我按下返回按钮,它将导航到浏览器(以前用于通过Twitter进行身份验证),而不是B,然后是A.我怎么能解决这个?

Gre*_*bin 8

请参考android中的Tasks和Back stack.您可以在应用程序中使用两个任务 - 第一个是您开展业务,第二个是授权.开始时你有意向标志授权FLAG_ACTIVITY_NEW_TASK和使用参数的android:clearTaskOnLaunch.祝好运!