我正在尝试建立从 android 设备到音乐流媒体平台 deezer 的连接。我遵循了开发人员教程,但一开始就遇到了麻烦。
建立连接工作正常,无论如何日志中没有任何故障。
connection = new DeezerConnectImpl(this, APP_ID);
在调用连接进行授权时
connection.authorize(this, PERMISSIONS, new ReconnectDialogHandler());
设备模拟器中出现了一个新的(而且是神秘的?)屏幕,显示以下消息:
我在开发人员页面和互联网上搜索了可能的解决方案,但我发现没有任何帮助......这个故障是怎么回事......?
这是完整的代码:
package com.example.deezertest2;
import android.app.Activity;
import android.os.Bundle;
import android.os.StrictMode;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.Toast;
import com.deezer.sdk.DeezerConnect;
import com.deezer.sdk.DeezerConnectImpl;
import com.deezer.sdk.DeezerError;
import com.deezer.sdk.DialogError;
import com.deezer.sdk.DialogListener;
import com.deezer.sdk.OAuthException;
import com.deezer.sdk.SessionStore;
public class MainActivity extends Activity {
private final String SECRET = "XXXXX";
public String access_token = "XXXXX";
private final String APP_ID = "XXXXX";
private final static String[] PERMISSIONS = new String[] {"basic_access","offline_access"};
private static final String LOG_TAG = "BaseActvt";
DeezerConnect connection;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
StrictMode.enableDefaults();
System.out.println("onCreate");
connection = new DeezerConnectImpl(this, APP_ID);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void loginButton(View view){
System.out.println("Button clicked");
connection.authorize(this, PERMISSIONS, new ReconnectDialogHandler());
}
protected class ReconnectDialogHandler implements DialogListener {
@Override
public void onComplete(final Bundle values) {
SessionStore sessionStore = new SessionStore();
sessionStore.save( connection, MainActivity.this );
Toast.makeText( MainActivity.this, R.string.user_authentified, Toast.LENGTH_LONG ).show();
}//met
@Override
public void onDeezerError(final DeezerError deezerError) {
Toast.makeText( MainActivity.this, R.string.deezer_error_during_login, Toast.LENGTH_LONG ).show();
Log.e( LOG_TAG, "DialogError error during login" , deezerError );
}//met
@Override
public void onError(final DialogError dialogError) {
Toast.makeText( MainActivity.this, R.string.deezer_error_during_login, Toast.LENGTH_LONG ).show();
Log.e( LOG_TAG, "DialogError error during login", dialogError );
}//met
@Override
public void onCancel() {
Toast.makeText( MainActivity.this, R.string.login_cancelled, Toast.LENGTH_LONG ).show();
}//met
@Override
public void onOAuthException(OAuthException oAuthException) {
Toast.makeText( MainActivity.this, R.string.invalid_credentials, Toast.LENGTH_LONG ).show();
}//met
}//inner class
}
和错误日志:
这是 Manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.deezertest2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.deezertest2.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>