का उपयोग कर स्थान और ईमेल नहीं प्राप्त किया जा सकता है मेरे एंड्रॉइड एप्लिकेशन में मैंने इस कोड को मेरे खाते से लॉगिन करने और नाम, स्थान और ईमेल जैसी उपयोगकर्ता संपत्ति प्राप्त करने के लिए विकसित किया। समस्या यह है कि मैं नाम प्राप्त कर सकता हूं, लेकिन मुझे ईमेल और स्थान नहीं मिल रहा है। जब मैंने बिना किसी कोशिश किए मेरे कोड की कोशिश की तो एप्लिकेशन क्रश और getproperty("email")
और getlocation()
में मेरा लॉग पॉइंट पकड़ने का प्रयास करें। जब मैं कोशिश का उपयोग करता हूं। आवेदन काम करता है लेकिन कोई ईमेल या स्थान नहीं है। हालांकि, अगर आप, एक पुराने फेसबुक एसडीके का उपयोग कर रहे हैं, जबकि newest SDK is 4.0.+फेसबुक एपीआई
authButton.setReadPermissions(Arrays.asList("user_likes", "user_status","email","user_birthday"));
:
public class Share extends Fragment {private static final String TAG ="Share";private UiLifecycleHelper uiHelper;
private View otherView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// To maintain FB Login session
uiHelper = new UiLifecycleHelper(getActivity(), callback);
uiHelper.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.share, container, false);
// Looks for Login button
LoginButton authButton = (LoginButton) view.findViewById(R.id.authButton);
authButton.setFragment(this);
// Set View that should be visible after log-in invisible initially
otherView = view.findViewById(R.id.other_views);
otherView.setVisibility(View.GONE);
//authButton.setReadPermissions(Arrays.asList("user_likes", "user_status","email","user_birthday"));
return view;
}
// Called when session changes
private Session.StatusCallback callback = new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state,Exception exception) {
onSessionStateChange(session, state, exception);
}
};
// When session is changed, this method is called from callback method
private void onSessionStateChange(Session session, SessionState state,Exception exception) {
final TextView name = (TextView) getView().findViewById(R.id.name);
final TextView mail = (TextView) getView().findViewById(R.id.mail);
final TextView location = (TextView) getView().findViewById(R.id.location);
final TextView locale = (TextView) getView().findViewById(R.id.locale);
final TextView info = (TextView)getView().findViewById(R.id.msginfo);
final LinearLayout views= (LinearLayout)getView().findViewById(R.id.other_views);
if (state.isOpened()) {
Log.i(TAG, "Logged in...");
// make request to the /me API to get Graph user
views.setVisibility(View.VISIBLE);
info.setText("You can now share images in facebook ");
Request.newMeRequest(session, new Request.GraphUserCallback() {
// callback after Graph API response with user
// object
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
try {
// Set view visibility to true
otherView.setVisibility(View.VISIBLE);
// Set User name
name.setText("Hello " + user.getName());
// Set Email
mail.setText("Your Email: " + user.getProperty("email").toString());
locale.setText("Locale: " + user.getProperty("locale").toString());
location.setText("Your Current Location: " + user.getLocation().getProperty("name").toString());
}
catch(Exception e) {
e.printStackTrace();
}
}
}
}).executeAsync();
} else if (state.isClosed()) {
views.setVisibility(View.INVISIBLE);
info.setText("If you want to share images in Facebook, please Login");
Log.i(TAG, "Logged out...");
otherView.setVisibility(View.GONE);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data);
Log.i(TAG, "OnActivityResult...");
}
@Override
public void onResume() {
super.onResume();
uiHelper.onResume();
}
@Override
public void onPause() {
super.onPause();
uiHelper.onPause();
}
@Override
public void onDestroy() {
super.onDestroy();
uiHelper.onDestroy();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
uiHelper.onSaveInstanceState(outState);
}
}
क्या आपने अनुमतियों के लिए कहा है? – Skynet
मुझे केवल इंटरनेट अनुमति की आवश्यकता है। मैं लॉगिन कर सकता हूं और अपनी छवि और मेरा उपयोगकर्ता नाम रख सकता हूं इसलिए मुझे नहीं लगता कि समस्या अनुमति में थी। – user3921905
फेसबुक अनुमतियां मैं बात कर रहा हूं! – Skynet