i was following the tutorial from facebook developer website to retrieve my profile name and show in apps but it is just return nothing but the word that i input myself in else condition. I had generate the android key hashes from my computer and put to my fb developer profile and the apps id had include in my android project as well....
package com.example.mobile_e_commerce;
import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.facebook.Request;
import com.facebook.Response;
import com.facebook.Session;
import com.facebook.SessionState;
import com.facebook.model.GraphUser;
public class SignInPage extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_in_page);
This is to open the facebook login
// start Facebook Login
Session.openActiveSession(this, true, new Session.StatusCallback() {
// callback when session changes state
#Override
public void call(Session session, SessionState state, Exception exception) {
the session should be opened i think but no///
if (session.isOpened()) {
// make request to the /me API
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
// callback after Graph API response with user object
#Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
The user should be my name, so it should output Hello Issac but return the else condition statement!
TextView welcome = (TextView) findViewById(R.id.welcome);
welcome.setText("Hello " + user.getName() + "!");
}
}
});
}
else
{
TextView welcome = (TextView) findViewById(R.id.welcome);
welcome.setText("User = Null");
}
}
});
/*
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}*/
}
to get the response from facebook activity
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
this part is just general android code
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.sign_in_page, menu);
return true;
}
this part is just general android code
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
this part is just general android code
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
this part is just general android code
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_sign_in_page,
container, false);
return rootView;
}
}
}
This happen because you are using the wrong key hash.
You should generate new hash key and use it instead of what you have now.
Related
I am new to Android Development and Facebook SDK. I am just trying to link Facebook loginButton with my application. When I click on button it ask me for login details and permissions and then it comes back successfully to app. But again at the same moment when I click on that button it ask me to login again.
package com.example.pranavjain.pranavapp;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.FacebookSdk;
import com.facebook.GraphRequest;
import com.facebook.GraphResponse;
import com.facebook.login.LoginResult;
import com.facebook.login.widget.LoginButton;
import org.json.JSONObject;
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
FacebookSdk.sdkInitialize(getApplicationContext());
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onCreateView(
LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_main, container, false);
LoginButton loginButton = (LoginButton) view.findViewById(R.id.login_button);
loginButton.setReadPermissions("user_friends");
// If using in a fragment
// Other app specific specialization
// Callback registration
CallbackManager callbackManager = CallbackManager.Factory.create();
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
// App code
GraphRequest request = GraphRequest.newMeRequest(
loginResult.getAccessToken(), new GraphRequest.GraphJSONObjectCallback() {
#Override
public void onCompleted(
JSONObject object1,
GraphResponse response) {
// Application code
Log.d("tagpranav", object1.toString());
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,link");
request.setParameters(parameters);
request.executeAsync();
}
#Override
public void onCancel() {
// App code
Log.v("LoginActivity", "cancel");
}
#Override
public void onError(FacebookException exception) {
// App code
Log.v("LoginActivity", exception.getCause().toString());
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
I have already checked that Hash key is right. Nothing gets logged under "tagpranav" or "LoginActivity".
Make sure to add following in your onCreate() method as first line:
FacebookSdk.sdkInitialize(getApplicationContext());
Consider moving your code in onCreate() method of your MainActivity. Below I'd mentioned working sample.
public class MainActivity extends ActionBarActivity {
CallbackManager callbackManager;
#Override
protected void onCreate(Bundle savedInstanceState) {
LoginButton loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton.setReadPermissions(PERMISSIONS_ARRAY);
callbackManager = CallbackManager.Factory.create();
// Callback registration
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
#Override
public void onSuccess(LoginResult loginResult) {
Log.i(TAG, "Logged in...");
GraphRequest.newMeRequest(AccessToken.getCurrentAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
#Override
public void onCompleted(JSONObject user, GraphResponse response) {
try {
if (user != null) {
Log.e(TAG, "UserID : " + user.getString("id"));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}).executeAsync();
}
#Override
public void onCancel() {
// Login canceled
}
#Override
public void onError(FacebookException exception) {
// Login error
}
});
}
}
In above code PERMISSIONS_ARRAY is array having all your permissions.
One thing you are missing is, make callbackManager class variable and add following method in your MainActivity.
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
Log.i(TAG, "OnActivityResult...:" + resultCode);
}
EDIT-1:
A class variable is something defined in a class and out side of method, so that all methods of class can access it.
In your code you have defined callbackManager inside a method, so you can't access it in onActivityResult. I have made relevant changes in my answer.
You have to pass the results to the callbackManager in onActivityResult like here: https://github.com/facebook/facebook-android-sdk/blob/master/samples/HelloFacebookSample/src/com/facebook/samples/hellofacebook/HelloFacebookSampleActivity.java#L231
I am currently attempting to generate a user profile in an Android application through the users existing social network data. I am using the SocialAuth library to login and pull the data out of the application and populate some text fields in a fragment.
I am currently using Facebook and Twitter for this but I am having trouble reciving the "Location" of the profile through Facebook. Twitter is able to get location successfully but Facebook simply comes up "Null" when the get request is sent out.
To complicate things when I access the Facebook account I am testing on with the example application that SocialAuth provides it is able to get the location without any problems but despite my code being identical and Twitter running the same code it won't work within my application.
Can anyone shed some light on why I am unable to retrieve the location through Facebook in my application? I will provide my relevant classes below:
LoginActivity.java
import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import org.brickred.socialauth.android.DialogListener;
import org.brickred.socialauth.android.SocialAuthAdapter;
import org.brickred.socialauth.android.SocialAuthError;
import org.brickred.socialauth.android.SocialAuthListener;
import org.brickred.socialauth.Profile;
public class LoginActivity extends ActionBarActivity {
private static SocialAuthAdapter adapter;
private Button facebook_button;
private Button twitter_button;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
adapter = new SocialAuthAdapter(new ResponseListener());
facebook_button = (Button)findViewById(R.id.fbSignUp);
twitter_button = (Button)findViewById(R.id.twitSignUp);
facebook_button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
adapter.authorize(LoginActivity.this, SocialAuthAdapter.Provider.FACEBOOK);
}
});
twitter_button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
adapter.authorize(LoginActivity.this, SocialAuthAdapter.Provider.TWITTER);
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_login, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
private class ResponseListener implements DialogListener {
#Override
public void onComplete(Bundle bundle) {
adapter.getUserProfileAsync(new ProfileDataListener());
}
#Override
public void onError(SocialAuthError socialAuthError) {
}
#Override
public void onCancel() {
}
#Override
public void onBack() {
}
}
private class ProfileDataListener implements SocialAuthListener<Profile> {
#Override
public void onExecute(String provider, Profile t) {
Profile profileMap = t;
Intent intent = new Intent(LoginActivity.this, HubPage.class);
intent.putExtra("provider", provider);
intent.putExtra("profile", profileMap);
startActivity(intent);
}
#Override
public void onError(SocialAuthError socialAuthError) {
}
}
}
Profile Fragment.java
import android.os.Bundle;
import android.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import org.brickred.socialauth.Profile;
import org.brickred.socialauth.android.SocialAuthAdapter;
public class ProfileFragment extends Fragment {
SocialAuthAdapter adapter;
Profile profileMap;
// Android Components
TextView name;
TextView location;
ImageView image;
// Variables
String provider_name;
//ImageLoader imageLoader;
public ProfileFragment() {
// Required empty public constructor
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_hub_page, container, false);
profileMap = (Profile) getActivity().getIntent().getSerializableExtra("profile");
Log.d("Profile", "Validate ID = " + profileMap.getValidatedId());
Log.d("Profile", "First Name = " + profileMap.getFirstName());
Log.d("Profile", "Last Name = " + profileMap.getLastName());
Log.d("Profile", "Location = " + profileMap.getLocation());
Log.d("Profile", "Profile Image URL = " + profileMap.getProfileImageURL());
provider_name = getActivity().getIntent().getStringExtra("provider");
// Set title
name = (TextView) rootView.findViewById(R.id.profileName);
location = (TextView) rootView.findViewById(R.id.profileLocation);
image = (ImageView) rootView.findViewById(R.id.profilePic);
//imageLoader = new ImageLoader(ProfileActivity.this);
//imageLoader.DisplayImage(profileMap.getProfileImageURL(), image);
// Name
if (profileMap.getFullName() == null)
name.setText(profileMap.getFirstName() + profileMap.getLastName());
else
name.setText(profileMap.getFullName());
// Location
location.setText(profileMap.getLocation());
return rootView;
}
}
Any help would be much appreciated as I can't seem to find any solution despite hours of trying.
I'm trying to create a session with Quickblox, but I'm never getting an answer from Quickblox. onConnect or onError is not firing. I'm testing from an emulator.
My Code:
package com.example.jdc.testjdclogin2;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import com.quickblox.auth.QBAuth;
import com.quickblox.auth.model.QBSession;
import com.quickblox.core.QBCallback;
import com.quickblox.core.QBEntityCallbackImpl;
import com.quickblox.core.QBSettings;
import com.quickblox.core.result.Result;
import com.quickblox.users.QBUsers;
import com.quickblox.users.model.QBUser;
import java.util.List;
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void LoginClicked(View view){
QBUser user = new QBUser();
user.setEmail("testuser#gmail.com");
user.setPassword("Abcd_1234");
QBSettings.getInstance().setApplicationId("19425");
QBSettings.getInstance().setAuthorizationKey("4DuqMR78cuBdMu9");
QBSettings.getInstance().setAuthorizationSecret("Tc8Ukxq-XUBLYz4");
QBAuth.createSession(new QBEntityCallbackImpl<QBSession>() {
#Override
public void onSuccess(QBSession session, Bundle params) {
// You have successfully created the session
//
// Now you can use QuickBlox API!
Log.i("Connection","session succeeded");
}
#Override
public void onError(List<String> errors) {
Log.i("Connection","session not succeeded");
}
});
QBUsers.signIn(user, new QBEntityCallbackImpl<QBUser>() {
#Override
public void onSuccess(QBUser user, Bundle params) {
Log.i("Connection","login succeeded");
}
#Override
public void onError(List<String> errors) {
Log.i("Connection","login not succeeded");
}
});
Log.i("Connection","End of procedure");
}
}
in the Logcat, I see the call to quickblox but never an answer. Any ideas?
Found the user => forgot to add the permission to use the internet
I am new to android development. I need a solution for the new app I am developing which takes voice input and gives output in voice by mapping with a mapping database. Current program takes voice input with onlick on button . I need a soultion which can take voice input without clicking of any button simliar to Talking Tom application . Here is my code.My main code is in speakToMe which is method called on onclick & onActivityResult
package com.example.secondprog;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Locale;
import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.speech.RecognizerIntent;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import android.os.Build;
import com.example.secondprog.*;
//import com.example.secondprog.DatabaseHelper;
public class MainActivity extends Activity {
private static final int VOICE_RECOGNITION_REQUEST = 0;
//private static final int VOICE_RECOGNITION_REQUEST = 0x10101;
TextToSpeech ttobj;
String resulttxt ;
TestDBClass db;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
db = new TestDBClass(this, null, null, 1);
try {
db.loadWords();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ttobj=new TextToSpeech(getApplicationContext(),
new TextToSpeech.OnInitListener() {
#Override
public void onInit(int status) {
if(status != TextToSpeech.ERROR){
ttobj.setLanguage(Locale.UK);
Toast.makeText(getApplicationContext(), "No error",
Toast.LENGTH_LONG).show();
}
}
});
//DatabaseHelper db = DatabaseHelper(this);
//dbdtls dbdtlsresult = new dbdtls();
//String message3 = db.getdtls("how are");
//String output = dbdtlsresult.new_name();
//EditText editText = (EditText) findViewById(R.id.edit_message);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment()).commit();
}
}
public void sendMessage(View view) {
EditText editText = (EditText) findViewById(R.id.edit_message);
String txt = editText.getText().toString();
// Toast.makeText(getApplicationContext(), txt.toUpperCase(),
// Toast.LENGTH_LONG).show();
DictonaryDAO dictonaryDAO =
db.findname(txt.toUpperCase());
if (dictonaryDAO != null) {
resulttxt = String.valueOf(dictonaryDAO.getnewname());
Toast.makeText(getApplicationContext(), resulttxt.toUpperCase(),
Toast.LENGTH_LONG).show();
}
ttobj.speak(resulttxt, TextToSpeech.QUEUE_FLUSH, null);
}
/*#Override
public void onPause(){
if(ttobj !=null){
ttobj.stop();
ttobj.shutdown();
}
super.onPause();
}
*/
**public void speakToMe(View view) {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT,
"Please speak slowly and enunciate clearly.");
startActivityForResult(intent, VOICE_RECOGNITION_REQUEST);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == VOICE_RECOGNITION_REQUEST && resultCode == RESULT_OK) {
ArrayList<String> matches = data
.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
// TextView textView = (TextView) findViewById(R.id.speech_io_text);
String firstMatch = matches.get(0);
// textView.setText(firstMatch);
DictonaryDAO dictonaryDAO =
db.findname(firstMatch.toUpperCase());
if (dictonaryDAO != null) {
resulttxt = String.valueOf(dictonaryDAO.getnewname());
Toast.makeText(getApplicationContext(), resulttxt.toUpperCase(),
Toast.LENGTH_LONG).show();
ttobj.speak(resulttxt, TextToSpeech.QUEUE_FLUSH, null);
}
}
}**
#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;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container,
false);
return rootView;
}
}
}
Voice Recognition not working for talking tom app so you try to use noise detection with sound meter. below here link for voice/ noise detection with audio recording without click.
http://androidexample.com/Detect_Noise_Or_Blow_Sound_-_Set_Sound_Frequency_Thersold/index.php?view=article_discription&aid=108&aaid=130
Please change SoundMeter.java File
mRecorder.setOutputFile(Environment.getExternalStorageDirectory().
getAbsolutePath() + "/test.3ggp");
This question already has answers here:
Login failed invalid key error with Facebook SDK
(13 answers)
Closed 8 years ago.
I was trying to make an app mentioned in https://developers.facebook.com/docs/android/getting-started/ but I am facing an issue. I can run the app and login with my FB account but I cannot get my name on Facebook.
This is the error when I try to get my name:
07-09 00:36:12.275: D/Request(28372): Warning: Sessionless Request needs token but missing either application ID or client token.
I think the problem is about authentication or some permission related to access FB database.
Any opinion would be appreciated..
And this is the code I am working on:
package com.example.firstface;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.Signature;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Base64;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import com.facebook.Request;
import com.facebook.Response;
import com.facebook.Session;
import com.facebook.SessionState;
import com.facebook.model.GraphUser;
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// start Facebook Login
Session.openActiveSession(this, true, new Session.StatusCallback() {
// callback when session changes state
#Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
Log.d("Info : ", session.getApplicationId());
// make request to the /me API
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) {
TextView welcome = (TextView) findViewById(R.id.welcome);
welcome.setText("hello " + user.getName() + "!");
}
}
}).executeAsync();
}
}
});
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
#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;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Remove onActivityResult from Fragment then add method on Activity page
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
It works for me !!!!!
This worked for me:
<string name="app_id">999999999999999</string>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/app_id" />