第一次发布一个问题,我很抱歉,这个问题有很多问题,但尝试了很多不同的选项后,我似乎无法得到它的工作。带有浏览器oauth的Android后退按钮返回到浏览器
我有一个推特应用程序,主屏幕上有一个按钮,通过标准浏览器应用程序请求oauth twitter访问,然后返回到主屏幕。如果我点击后退按钮,浏览器应用程序将打开twitter网站。我已经在manifest文件中尝试了noHistory,并且在许多场景中没有运气的情况下启动intent FLAG_ACTIVITY_NO_HISTORY以及FLAG_ACTIVITY_CLEAR_TOP和Intent.FLAG_ACTIVITY_SINGLE_TOP。
这里是我的最新代码:
清单文件
<activity android:name=".oauth"
android:label="@string/oauth_name"
android:noHistory="true"
>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tm" android:host="twitt" />
</intent-filter>
</activity>
<activity android:name="com.tweetymanagerpro.Home"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar"
android:windowSoftInputMode="stateHidden|adjustPan">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
在家庭活动中,我将OAuth如下
Intent settingsActivity = new Intent(getBaseContext(), oauth.class);
settingsActivity.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(settingsActivity);
接下来,在oauth.onCreate()我致电Twitter的网址
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl));
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
this.startActivity(intent);
接下来,在oauth.onResume()我办理令牌等,然后开始再次回家
Intent i = new Intent(this, Home.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(i);
到Twitter的连接的伟大工程,它现在只是在家里,如果我打的后退按钮需要我回浏览器使用twitter进行身份验证。
感谢您的回复。实际对浏览器活动的调用是使用Uri.parse(authUrl)的上面的代码。我尝试过使用完成,我将它添加回来并发布结果。 – Rob 2012-02-28 02:36:28
我加了每次通话后结束()调用一个新的活动,现在一旦我回到了家活动,我打后退按钮,并有选择的应用程序的一个非常快速的闪光发射活动屏幕,这是它。第二次点击后退按钮关闭应用程序。这对我有用,感谢信息黑社会! – Rob 2012-02-28 05:56:10