我在我的應用程序中使用單點登錄(http://developers.facebook.com/docs/mobile/android/build/)。它似乎在模擬器上正常工作(我成功登錄並獲取access_token)。但在我的Nexus S中,webview顯示,但我總是「登錄失敗」。Facebook sdk(單一登錄)沒有在設備上工作
有我的代碼:
((Button)findViewById(R.id.BtnFacebook)).setOnClickListener(new OnClickListener(){
public void onClick(View v) {
//startActivity(intentLoginFacebook);
facebook.authorize(Login.this, new String[] {"user_about_me","user_activities","user_birthday","user_education_history","user_events","user_groups","user_hometown","user_interests","user_likes","user_location","user_religion_politics","user_status","user_website","user_work_history","read_requests","read_stream","friends_events","email","create_event","manage_friendlists","offline_access","rsvp_event"}, new DialogListener() {
@Override
public void onComplete(Bundle values) {
String id = "";
String access_token = facebook.getAccessToken();
System.out.println("ACCESSTOKENNNN:" + access_token);
try {
String response = facebook.request("me");
JSONObject obj = new JSONObject(response);
id = obj.getString("id");
System.out.println("response: "+response);
} catch (IOException ex) {
Log.d("Facebook", ex.getMessage());
} catch (Exception e) {
Log.d("Facebook", e.getMessage());
}
//Verification du login/password
new LoginFacebook().execute(id,access_token);
System.out.println("IDDDDDDDD:" + id);
}
@Override
public void onFacebookError(FacebookError error) {
Toast.makeText(getApplicationContext(), "Facebook error: login failed", Toast.LENGTH_LONG).show();
}
@Override
public void onCancel() {
}
@Override
public void onError(DialogError e) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(), "Login failed", Toast.LENGTH_LONG).show();
}
});
}
});
感謝您的幫助!
清除瀏覽器Cookie和運行應用程序用乾淨的構建項目 –
沒有工作.... – user420574
@ user420574你能解釋一下如何ü創建哈希鍵..問題會with Hash Key .. – Venky