登录期间Deezer android sdk UI冻结

时间:2014-05-13 09:06:05

标签: deezer

我在我的应用程序中实现了Deeezer android SDK,我有一个用户无法在其Motorola Razr I上登录其Deezer帐户。登录UI在此页面上冻结,应用程序重新启动。他在其他设备上没有遇到这个问题。

我使用的SDK版本是0.9.3

以下是应用程序冻结的页面的屏幕截图。

Deezer UI login 什么样的信息有助于确定问题?

修改

以下是源代码:

public class LoginActivity extends Activity
{
    protected static final String[] PERMISSIONS = new String[] {"basic_access", "manage_library", "delete_library", "listening_history", "manage_community"};

    // DeezerConnect object
    private DeezerConnect   m_deezerConnect;

    // Handle connection callbacks.
    private DialogHandler   m_dialogHandler     = new DialogHandler();

    // if the authentication failed, retry once
    private boolean         m_firstTry          = true;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login_activity);

        m_deezerConnect = new DeezerConnectImpl(getString(R.string.deezer_app_id));

        SessionStore sessionStore = new SessionStore();

        AlertDialog.Builder deezerAuthDialog = new AlertDialog.Builder(this);

        deezerAuthDialog.setTitle(R.string.deezer_authentication);
        deezerAuthDialog.setMessage(R.string.enter_deezer_credentials);
        deezerAuthDialog.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener()
        {
            @Override
            public void onClick(DialogInterface dialog, int which)
            {
                dialog.dismiss();
                connectToDeezer(m_dialogHandler);
            }
        });

        deezerAuthDialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener()
        {
            @Override
            public void onClick(DialogInterface dialog, int which)
            {
                dialog.dismiss();
                finish();
            }
        });

        deezerAuthDialog.setOnCancelListener(new DialogInterface.OnCancelListener()
        {
            @Override
            public void onCancel(DialogInterface dialog)
            {
                finish();
            }
        });

        deezerAuthDialog.show();
    }


    @Override
    public void onResume()
    {
        super.onResume();
    }

    @Override
    public void onDestroy()
    {
        super.onDestroy();
    }

    /**
     * Connects to Deezer web services using an injectable DialogListener listener.
     * @param listener event listener that will be notified of the connection progress.
     */
    private void connectToDeezer(final DialogListener listener)
    {
        m_deezerConnect.authorize(this, PERMISSIONS, listener);
    }

    /** Handle DeezerConnect callbacks. */
    private class DialogHandler implements DialogListener
    {
        @Override
        public void onComplete(final Bundle values)
        {
            SessionStore sessionStore = new SessionStore();
            sessionStore.save(m_deezerConnect, LoginActivity.this);

            LoginActivity.this.finish();
        }

        @Override
        public void onDeezerError(final DeezerError deezerError)
        {
            Log.e(DeemoteGlobals.TAG, "DialogError error during login" , deezerError );
            LoginActivity.this.finish();
        }

        @Override
        public void onError(final DialogError dialogError)
        {
            // the api returns an error while the authentication succeed, so we force a retry once
            int errorCode = dialogError.getErrorCode();
            if (errorCode == -10 && m_firstTry)
            {
                    m_firstTry = false;
                    connectToDeezer(m_dialogHandler);
                    return;
                }

            Log.e(DeemoteGlobals.TAG, "DialogError error during login", dialogError);
            }

            LoginActivity.this.finish();
        }

        @Override
        public void onCancel()
        {
            LoginActivity.this.finish();
        }

        @Override
        public void onOAuthException(OAuthException oAuthException)
        {
            LoginActivity.this.finish();
        }
    }
}

0 个答案:

没有答案