第一次發佈一個問題,我很抱歉,這個問題有很多問題,但嘗試了很多不同的選項後,我似乎無法得到它的工作。帶有瀏覽器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