0
我使用Facebook的SDK 4.14它裝置dosent有Facebooklite應用propely工作與Facebook登錄無法在具有Facebooklite應用程序的設備上工作?
FacebookSdk.sdkInitialize(MainActivity.this);
final Dialog dlg = new Dialog(MainActivity.this);
dlg.requestWindowFeature(Window.FEATURE_NO_TITLE);
dlg.setContentView(R.layout.fblogindilog);
TextView continuew=(TextView)dlg.findViewById(R.id.cont);
TextView fbusername=(TextView)dlg.findViewById(R.id.usname);
lgnfb = (LoginButton) dlg.findViewById(R.id.fblogin);
AccessToken accessToken = AccessToken.getCurrentAccessToken();
if (accessToken == null) {
dlg.show();
lgnfb.setReadPermissions(Arrays.asList("public_profile, email, user_birthday"));
callbackManager = CallbackManager.Factory.create();
lgnfb.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
GraphRequest request=GraphRequest.newMeRequest(loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
GetNameId(object);
}
});
Bundle parameters=new Bundle();
parameters.putString("fields","id,name,email,gender,birthday");
request.setParameters(parameters);
request.executeAsync();
dlg.dismiss();
Intent intent = new Intent(MainActivity.this, Sujab.class);
startActivity(intent);
}
@Override
public void onCancel() {
Toast.makeText(MainActivity.this, "login cancled", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(FacebookException error) {
Toast.makeText(MainActivity.this, "unable to connect with facebook your internet is slow", Toast.LENGTH_SHORT).show();
}
});
}
else {
continuew.setText("Continue with same account");
SharedPreferences sp=getSharedPreferences("USERINFO",Context.MODE_PRIVATE);
String namefb=sp.getString("Name"," ");
fbusername.setText("Welcome! "+namefb);
dlg.show();
continuew.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this, Sujab.class);
startActivity(intent);
}
});
lgnfb.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainActivity.this, "You are sucessfuly logout please login for sujab", Toast.LENGTH_SHORT).show();
dlg.dismiss();
}
});
和
private void GetNameId(JSONObject object) {
try {
name=object.getString("name");
userid=object.getString("id");
Log.d("Name::",name);
Log.d("id::",userid);
sharedPreferences= getSharedPreferences("USERINFO",Context.MODE_PRIVATE);
SharedPreferences.Editor ed=sharedPreferences.edit();
ed.putString("Name",name);
ed.putString("Id",userid);
ed.clear();
ed.commit();
}catch (Exception e){
e.printStackTrace();
}
}
但是,當我在具有設備安裝裝配此apk Facebooklite應用程式,直接開facebooklite什麼是問題?
感謝它爲我工作 –