为Android Dropbox的核心API:活动认证后停止核心、Android、Dropbox、API

2023-09-07 01:52:20 作者:失宠的猫

我的可能面临同样的情况Dropbox Android的核心API:认证后没有返回,但这个问题仍然没有答案,所以我决定问

我开发一个Android应用程序,其中用户可以拥有多个账户,其中一个是投寄箱。我创造了这个帐户的自定义列表,单击此Dropbox的名单上我开始一个意图

 如果(位置== DROPBOX_LOGIN) {      意向意图=新意图(活动,DropboxLogin.class);      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);              context.startActivity(意向); } 

用户随后被带到登录的Dropbox的活性的研究进一步很快就有自带的应用程序authentication.As作为用户presses接受或拒绝,浏览器不会消失。它保持开放,DropboxLogin没有得到恢复(onResume不叫!)。

有没有人遇到这个问题呢?什么是贯彻意图,使用户可以从Dropbox的同意画面comeout正确的方法是什么?它需要额外的标志吗?

-------------编辑---------------------

这是我的授权DropboxLogin类

  @覆盖保护无效的onCreate(捆绑savedInstanceState){    super.onCreate(savedInstanceState);    的setContentView(R.layout.main2);    preFS = getShared preferences(ListActivity.Dropbox_ preFS_NAME,0);    //我们创建一个新AuthSession,这样我们就可以使用Dropbox的API。    AndroidAuthSession会话= buildSession();    MAPI =新DropboxAPI< AndroidAuthSession>(会话);    //基本的Andr​​oid小工具    checkAppKeySetup();    如果(USE_OAUTH1)    {        Log.d(使用,的OAuth 1);        。mApi.getSession()startAuthentication(finaldrop.this);    }    其他    {        Log.d(使用,OAuth的2);        。mApi.getSession()startOAuth2Authentication(finaldrop.this);    }  }   @覆盖   保护无效onResume()   {    super.onResume();    AndroidAuthSession会话= mApi.getSession();    //接下来的部分必须的的onResume()方法被插入    //活动从session.startAuthentication()被调用,所以    //这Dropbox的验证正确完成。    如果(session.authenticationSuccessful())    {        尝试        {            Log.d(投寄箱,onresume);            //强制收回来完成身份验证            session.finishAuthentication();            //我们供以后使用的应用程序在本地存储它            storeAuth(会话);        }        赶上(IllegalStateException异常E)        {            showToast(无法​​与Dropbox的验证:+ e.getLocalizedMessage());            Log.i(TAG,错误认证,E);        }    }} 

解决方案

我加入解决我的问题。

 的android:launchMode =singleTask 
想为 Android 机做一次全面备份, 你有这些方案可以选择

在我的应用程序的清单。

I am "probably facing" same situation as Dropbox Core API for Android: Not returning after Authentication but this question is still unanswered so i decided to ask.

I am developing an android application where user can have multiple accounts,one of them is dropbox. i have created a custom list of this accounts, clicking on this dropbox list i am starting an intent

 if(position==DROPBOX_LOGIN)
 {
      Intent intent =new Intent(activity,DropboxLogin.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
              context.startActivity(intent);
 }

user is then taken to login acitivity of dropbox further there comes app authentication.As soon as the user presses 'Accept' or 'Decline', the browser does not disappear. It stays open and DropboxLogin does not get resumed (onResume is not called!).

has anyone faced this problem too? what is the correct way to implement intent so that user can comeout from Dropbox consent screen? does it need Additional flags?

-------------EDIT---------------------

here is my DropboxLogin class for authorization

     @Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);

    setContentView(R.layout.main2);
    prefs = getSharedPreferences(ListActivity.Dropbox_PREFS_NAME, 0);

    // We create a new AuthSession so that we can use the Dropbox API.
    AndroidAuthSession session = buildSession();
    mApi = new DropboxAPI<AndroidAuthSession>(session);

    // Basic Android widgets



    checkAppKeySetup();
    if (USE_OAUTH1) 
    {
        Log.d("uses ", "oauth 1");
        mApi.getSession().startAuthentication(finaldrop.this);
    }
    else 
    {
        Log.d("uses ", "oauth 2");
        mApi.getSession().startOAuth2Authentication(finaldrop.this);
    }
  }
   @Override
   protected void onResume() 
   {
    super.onResume();
    AndroidAuthSession session = mApi.getSession();

    // The next part must be inserted in the onResume() method of the
    // activity from which session.startAuthentication() was called, so
    // that Dropbox authentication completes properly.
    if (session.authenticationSuccessful()) 
    {
        try 
        {
            Log.d("Dropbox", "onresume");
            // Mandatory call to complete the auth
            session.finishAuthentication();

            // Store it locally in our app for later use
            storeAuth(session);
        }
        catch (IllegalStateException e) 
        {
            showToast("Couldn't authenticate with Dropbox:" + e.getLocalizedMessage());
            Log.i(TAG, "Error authenticating", e);
        }
    }
}

解决方案

I solved my problem by adding

 android:launchMode="singleTask"

in my app's manifest.