2014-11-20 97 views
0

我試圖將Twitter集成到我的應用程序中(即使您從未這樣做過,請繼續閱讀)。這是登錄流程:活動打開外部應用程序,打開活動,從而使其在活動堆棧中翻倍

  1. 用戶點擊活動
  2. Twitter的認證網站在瀏覽器中出現「與Twitter登錄」。用戶點擊允許應用使用Twitter
  3. 瀏覽器消失,活動再次打開。

問題是,活動打開AGAIN,這意味着點擊後我仍然在這個活動(就在用Twitter登錄之前),所以我需要再次單擊BACK。

這是打開Twitter的授權網站在瀏覽器中的行:

SettingsActivity.this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(requestToken.getAuthenticationURL()))); 

finish()後,它並不能幫助。

甚至沒有設置FLAG_ACTIVITY_CLEAR_TOP:

Intent intent = new Intent(Intent.ACTION_VIEW); 
    intent.setData(Uri.parse(requestToken.getAuthenticationURL())); 
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    startActivity(intent); 

任何想法?

回答

0

您是否在清單中設置了活動android:launchMode="singleInstance"

還可以使用此:

intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);