How to share app link on facebook without have the app installed? - android

I am using the sdk from facebook to share my app link. When I have the facebook app installed on my device, it works fine.
But I want that the user can share it without have the app installed on device.
The link to the tutorial from facebook to do that is broken and I get this example of Feed Dialog on the internet:
private void publishFeedDialog() {
Session session = Session.getActiveSession();
Bundle params = new Bundle();
params.putString("name", "***");
params.putString("caption", "***");//caption
params.putString("picture", ***");
params.putString("link", "***");
Request.Callback callback = new Request.Callback() {
public void onCompleted(Response response) {
FacebookRequestError error = response.getError();
if (error != null) {
Log.i("Tag", "FacebookRequestError" + error.getErrorMessage());
Toast.makeText(CompartilhamentoActivity.this, error.getErrorMessage(), Toast.LENGTH_SHORT).show();
} else {
Log.i("Tag", "FacebookRequest Done");
Toast.makeText(CompartilhamentoActivity.this, "Story Published to Your Wall", Toast.LENGTH_LONG).show();
}
}
};
Request request = new Request(session, "me/feed", params, HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
}
When I use this method I get this error "FacebookRequestErrorcom.facebook.FacebookException: Session provided to a Request in un-opened state."

Check this one
public class FacebookActivity extends Activity {
String p_name;
String p_desc;
String path;
String timeStamp;
String senduri;
Boolean canshare=false;
private static final String PERMISSION = "publish_actions";
int fun=0;
SharedPreferences settings;
WebDialog feedDialog;
Button facebookButton;
private static final String TAG = "Facebook";
boolean isClicked=false;
private Session.StatusCallback statusCallback =
new Session.StatusCallback() {
#Override
public void call(Session session,
SessionState state, Exception exception) {
onSessionStateChange(session, state, exception);
}
};
private static final List<String> PERMISSIONS = Arrays.asList("publish_actions");
private static final String PENDING_PUBLISH_KEY = "pendingPublishReauthorization";
private boolean pendingPublishReauthorization = false;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_facebook);
//facebook connector initialization************************
Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
Session session = Session.getActiveSession();
if (session == null) {
if (savedInstanceState != null) {
session = Session.restoreSession(this, null, statusCallback, savedInstanceState);
}
if (session == null) {
session = new Session(this);
}
Session.setActiveSession(session);
if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) {
}
}
try {
PackageInfo info = getPackageManager().getPackageInfo(
getApplicationContext().getPackageName(), PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures)
{
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException ex) {
} catch (NoSuchAlgorithmException ex2) {
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.facebook, menu);
return true;
}
#Override
protected void onStart() {
Log.d(TAG, "onStart");
super.onStart();
Session.getActiveSession().addCallback(statusCallback);
}
#Override
protected void onDestroy() {
Log.d(TAG, "onDestroy");
super.onDestroy();
}
#Override
public void onStop() {
Log.d(TAG, "onStop");
super.onStop();
Session.getActiveSession().removeCallback(statusCallback);
}
public void onClickPublishPic(View v) {
//postPhoto();
fun=1;
onClickLogin();
isClicked=true;
}
public void onClickPublishStory(View v) {
//postPhoto();
fun=2;
onClickLogin();
isClicked=true;
}
protected void onSessionStateChange(Session session, SessionState state,
Exception exception) {
session = Session.getActiveSession();
if (session.isOpened()) {
if(fun==1){
postPhoto();
}else if(fun==2){
publishStory();
}
} else {
//nothing .. maybe message
}
}
private void onClickLogin() {
Session.openActiveSession(this, true, statusCallback);
}
#Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Session session = Session.getActiveSession();
Session.saveSession(session, outState);
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
//Session.openActiveSession(this, true, statusCallback);
Log.d("msg"," "+resultCode);
}
private void postPhoto() {
Session session = Session.getActiveSession();
if (session != null) {
//pendingAction = action;
if (hasPublishPermission()) {
Bitmap image = BitmapFactory.decodeResource(this.getResources(), R.drawable.ic_launcher);
Request request = Request.newUploadPhotoRequest(session, image, new Request.Callback() {
#Override
public void onCompleted(Response response) {
//showPublishResult(getString(R.string.app_name), response.getGraphObject(), response.getError());
Toast.makeText(getBaseContext(),
"Image Uploaded to facebook",
Toast.LENGTH_SHORT).show();
}
});
Bundle params = request.getParameters();
params.putString("name", "My Science Lab Diagram");
request.setParameters(params);
Request.executeBatchAsync(request);
// We can do the action right away.
//handlePendingAction();
//return;
} else if (session.isOpened()) {
// We need to get new permissions, then complete the action when we get called back.
session.requestNewPublishPermissions(new Session.NewPermissionsRequest(this, PERMISSION));
//return;
}
}
}
private void publishStory() {
Session session = Session.getActiveSession();
if (session != null){
// Check for publish permissions
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session
.NewPermissionsRequest(this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
Bundle postParams = new Bundle();
postParams.putString("name", "Facebook SDK for Android");
postParams.putString("caption", "Build great social apps and get more installs.");
postParams.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
postParams.putString("link", "https://developers.facebook.com/android");
postParams.putString("picture", "https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");
Request.Callback callback= new Request.Callback() {
public void onCompleted(Response response) {
JSONObject graphResponse = response
.getGraphObject()
.getInnerJSONObject();
String postId = null;
try {
postId = graphResponse.getString("id");
} catch (JSONException e) {
Log.i(TAG,
"JSON error "+ e.getMessage());
}
FacebookRequestError error = response.getError();
if (error != null) {
Toast.makeText(FacebookActivity.this
.getApplicationContext(),
error.getErrorMessage(),
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(FacebookActivity.this
.getApplicationContext(),
postId,
Toast.LENGTH_LONG).show();
}
}
};
Request request = new Request(session, "me/feed", postParams,
HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
}
}
private boolean isSubsetOf(Collection<String> subset, Collection<String> superset) {
for (String string : subset) {
if (!superset.contains(string)) {
return false;
}
}
return true;
}
private boolean hasPublishPermission() {
Session session = Session.getActiveSession();
return session != null && session.getPermissions().contains("publish_actions");
}
}

Related

Get friend list using latest facebook sdk in android

MainActivity.java
public class MainActivity extends ActionBarActivity {
RequestAsyncTask task = null;
private SharedPreferences preferences;
private String AccessToken = "";
private static final List<String> PERMISSIONS = Arrays
.asList("publish_actions");
private static final List<String> PERMISSIONSFRD = Arrays
.asList("user_friends");
private static final String PENDING_PUBLISH_KEY = "pendingPublishReauthorization";
private boolean pendingPublishReauthorization = false;
private LoginButton btn_fb_login;
private UiLifecycleHelper uiHelper;
private PendingAction pendingAction = PendingAction.NONE;
private GraphUser user;
private final String PENDING_ACTION_BUNDLE_KEY = "com.facebook.samples.hellofacebook:PendingAction";
private enum PendingAction {
NONE, POST_PHOTO, POST_STATUS_UPDATE
}
private Session.StatusCallback callback = new Session.StatusCallback() {
#Override
public void call(Session session, SessionState state,
Exception exception) {
onSessionStateChange(session, state, exception);
}
};
private FacebookDialog.Callback dialogCallback = new FacebookDialog.Callback() {
#Override
public void onError(FacebookDialog.PendingCall pendingCall,
Exception error, Bundle data) {
// Log.e("HelloFacebook", String.format("Error: %s",
// error.toString()));
}
#Override
public void onComplete(FacebookDialog.PendingCall pendingCall,
Bundle data) {
// Log.e("HelloFacebook", "Success!");
}
};
private Button btn_share_fb;
Button btn_frds;
private boolean isShareProcess = false;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uiHelper = new UiLifecycleHelper(this, callback);
uiHelper.onCreate(savedInstanceState);
if (savedInstanceState != null) {
String name = savedInstanceState
.getString(PENDING_ACTION_BUNDLE_KEY);
pendingAction = PendingAction.valueOf(name);
}
System.out.println("Start");
Log.e("FB LOGIN--->", "----->Login");
setContentView(R.layout.activity_main);
preferences = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
btn_share_fb = (Button) findViewById(R.id.btn_share_fb);
btn_frds = (Button)findViewById(R.id.btn_frds);
btn_frds.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
getFrdList();
}
});
btn_fb_login = (LoginButton) findViewById(R.id.btn_fb_login);
btn_fb_login.setReadPermissions(Arrays.asList("basic_info", "email",
"user_birthday", "user_location"));
btn_fb_login.setUserInfoChangedCallback(new UserInfoChangedCallback() {
#Override
public void onUserInfoFetched(GraphUser user) {
// TODO Auto-generated method stub
MainActivity.this.user = user;
try {
Session session = Session.getActiveSession();
boolean enableButtons = (session != null && session
.isOpened());
if (enableButtons && user != null) {
Log.e("-->", "" + session.getPermissions());
Log.e("fb user.getId", "" + user.getId());
Log.e("fb user.getFirstName",
"" + user.getFirstName());
Log.e("fb user.getMiddleName",
"" + user.getMiddleName());
Log.e("fb user.getLastName",
"" + user.getLastName());
Log.e("fb user.getUsername",
"" + user.getUsername());
Log.e("fb user.getBirthday",
"" + user.getBirthday());
Log.e("fb user.getLocation",
"" + user.getLocation());
Log.e("fb user.gender",
""
+ user.asMap().get("gender")
.toString());
Log.e("fb user email", "Email "
+ user.asMap().get("email"));
AccessToken = session.getAccessToken();
Editor PEDIT = preferences.edit();
PEDIT.putBoolean(
GeneralClass.temp_isFbLoginShare, true);
PEDIT.commit();
setFbLoginDetails1();
} else {
// profilePictureView.setProfileId(null);
// greeting.setText(null);
// btn_fb_login.setVisibility(View.VISIBLE);
Log.e("FB--->", "----> NOT LOGIN");
Editor PEDIT = preferences.edit();
PEDIT.putBoolean(
GeneralClass.temp_isFbLoginShare, false);
PEDIT.commit();
}
} catch (Exception e) {
e.printStackTrace();
// Log.e("error get facebook details-->",
// "error get facebook details");
}
handlePendingAction();
}
});
btn_share_fb.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(!FbSharing.checkUserFBLogin()){
if (preferences.getBoolean(
GeneralClass.temp_isFbLoginShare, false) == true) {
// publishFeedDialog();
/**
* original method
* */
Session session = Session.getActiveSession();
boolean enableButtons = (session != null && session
.isOpened());
if (enableButtons) {
publishStory();
isShareProcess = true;
} else {
// Log.e("error:",
// "please login again in facebook");
}
// share();
// getListofFacebookFriend();
} else {
GeneralClass.showToast("Please login with Facebook",
getApplicationContext());
btn_fb_login.setVisibility(View.VISIBLE);
}
}else if(FbSharing.checkUserFBLogin()){
try {
publishStory();
} catch (Exception e) {
// Log.e("error share facebook user",
// "error share facebook user");
e.printStackTrace();
}
}
}
});
setFbLoginDetails();
}
protected void setFbLoginDetails() {
if (FbSharing.checkUserFBLogin()) {
btn_fb_login.setVisibility(View.GONE);
btn_share_fb.setVisibility(View.VISIBLE);
} else if (preferences.getBoolean(GeneralClass.temp_isFbLoginShare,
false) == true) {
btn_fb_login.setVisibility(View.GONE);
btn_share_fb.setVisibility(View.VISIBLE);
} else {
btn_fb_login.setVisibility(View.GONE);
btn_share_fb.setVisibility(View.VISIBLE);
}
}
protected void setFbLoginDetails1() {
if (FbSharing.checkUserFBLogin()) {
btn_fb_login.setVisibility(View.GONE);
btn_share_fb.setVisibility(View.VISIBLE);
} else if (preferences.getBoolean(GeneralClass.temp_isFbLoginShare,
false) == true) {
btn_fb_login.setVisibility(View.VISIBLE);
btn_share_fb.setVisibility(View.VISIBLE);
} else {
btn_fb_login.setVisibility(View.GONE);
btn_share_fb.setVisibility(View.VISIBLE);
}
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data, dialogCallback);
}
#Override
protected void onResume() {
super.onResume();
uiHelper.onResume();
// Call the 'activateApp' method to log an app event for use in
// analytics and advertising reporting. Do so in
// the onResume methods of the primary Activities that an app may be
// launched into.
AppEventsLogger.activateApp(this);
updateUI("onResume");
}
#Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
uiHelper.onSaveInstanceState(outState);
outState.putString(PENDING_ACTION_BUNDLE_KEY, pendingAction.name());
}
#Override
public void onPause() {
super.onPause();
uiHelper.onPause();
}
#Override
public void onDestroy() {
super.onDestroy();
uiHelper.onDestroy();
}
private void onSessionStateChange(Session session, SessionState state,
Exception exception) {
if (pendingAction != PendingAction.NONE
&& (exception instanceof FacebookOperationCanceledException || exception instanceof FacebookAuthorizationException)) {
new AlertDialog.Builder(MainActivity.this)
.setTitle(R.string.cancelled)
.setMessage(R.string.permission_not_granted)
.setPositiveButton(R.string.ok, null).show();
pendingAction = PendingAction.NONE;
} else if (state == SessionState.OPENED_TOKEN_UPDATED) {
handlePendingAction();
}
updateUI("onSessionStateChange");
}
#SuppressWarnings("incomplete-switch")
private void handlePendingAction() {
PendingAction previouslyPendingAction = pendingAction;
// These actions may re-set pendingAction if they are still pending, but
// we assume they
// will succeed.
pendingAction = PendingAction.NONE;
switch (previouslyPendingAction) {
case POST_PHOTO:
// postPhoto();
break;
case POST_STATUS_UPDATE:
// postStatusUpdate();
break;
}
}
private void updateUI(String fromWhere) {
// Log.e("fromWhere", "" + fromWhere);
Session session = Session.getActiveSession();
boolean enableButtons = (session != null && session.isOpened());
if (enableButtons && user != null) {
AccessToken = session.getAccessToken();
Editor PEDIT = preferences.edit();
PEDIT.putBoolean(GeneralClass.temp_isFbLoginShare, true);
PEDIT.commit();
setFbLoginDetails();
} else {
Editor PEDIT = preferences.edit();
PEDIT.putBoolean(GeneralClass.temp_isFbLoginShare, false);
PEDIT.commit();
}
}
public void share() {
try {
Session session = Session.getActiveSession();
boolean enableButtons = (session != null && session.isOpened());
if (enableButtons) {
Bundle bundle = new Bundle();
bundle.putString("caption", "Harlem Shake Launcher for Android");
bundle.putString("description",
"Your android can do the Harlem Shake. Download it from google play");
bundle.putString("link",
"https://play.google.com/store/apps/details?id=mobi.shush.harlemlauncher");
bundle.putString("name", "Harlem Shake Launcher");
bundle.putString("picture", "http://shush.mobi/bla.png");
new WebDialog.FeedDialogBuilder(getApplicationContext(),
Session.getActiveSession(), bundle).build().show();
}
} catch (Exception e) {
// Log.e("error share on facebook", "error share on facebook");
e.printStackTrace();
}
}
#SuppressWarnings("unused")
private void publishFeedDialog() {
try {
Session session = Session.getActiveSession();
boolean enableButtons = (session != null && session.isOpened());
if (enableButtons) {
Bundle params = new Bundle();
params.putString("name", "Facebook SDK for Android");
params.putString("caption",
"Build great social apps and get more installs.");
params.putString(
"description",
"The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
params.putString("link",
"https://developers.facebook.com/android");
params.putString("picture",
"https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");
WebDialog feedDialog = (new WebDialog.FeedDialogBuilder(
getApplicationContext(), Session.getActiveSession(),
params)).setOnCompleteListener(
new OnCompleteListener() {
#Override
public void onComplete(Bundle values,
FacebookException error) {
if (error == null) {
// When the story is posted, echo the
// success
// and the post Id.
final String postId = values
.getString("post_id");
if (postId != null) {
Toast.makeText(getApplicationContext(),
"Posted story, id: " + postId,
Toast.LENGTH_SHORT).show();
} else {
// User clicked the Cancel button
Toast.makeText(
getApplicationContext()
.getApplicationContext(),
"Publish cancelled",
Toast.LENGTH_SHORT).show();
}
} else if (error instanceof FacebookOperationCanceledException) {
// User clicked the "x" button
Toast.makeText(
getApplicationContext()
.getApplicationContext(),
"Publish cancelled",
Toast.LENGTH_SHORT).show();
} else {
// Generic, ex: network error
Toast.makeText(
getApplicationContext()
.getApplicationContext(),
"Error posting story",
Toast.LENGTH_SHORT).show();
}
}
}).build();
feedDialog.show();
}
} catch (Exception e) {
// Log.e("error share on facebook", "error share on facebook");
e.printStackTrace();
}
}
private boolean isSubsetOf(Collection<String> subset,
Collection<String> superset) {
for (String string : subset) {
if (!superset.contains(string)) {
return false;
}
}
return true;
}
private void publishStory() {
Session session = Session.getActiveSession();
if (session != null) {
GeneralClass.showToast("Wait while we share in facebook",
getApplicationContext());
// Check for publish permissions
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(
this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
Bundle postParams = new Bundle();
postParams.putString("name", "Lolipop for Android");
postParams.putString("caption",
"Get better experience!");
postParams.putString("description",
"Get better experience!");
postParams.putString("link",
"https://developers.facebook.com/android");
postParams
.putString("picture",
"https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");
Request.Callback callback = new Request.Callback() {
public void onCompleted(Response response) {
JSONObject graphResponse = response.getGraphObject()
.getInnerJSONObject();
String postId = null;
try {
postId = graphResponse.getString("id");
} catch (JSONException e) {
Log.i("-->", "JSON error " + e.getMessage());
}
FacebookRequestError error = response.getError();
if (error != null) {
Toast.makeText(getApplicationContext(),
error.getErrorMessage(), Toast.LENGTH_SHORT)
.show();
isShareProcess = false;
} else {
Toast.makeText(
getApplicationContext(),
"Successfully Shared on Facebook, postid - "
+ postId, Toast.LENGTH_LONG).show();
isShareProcess = false;
new GetLists().execute();
}
task = null;
}
};
Request request = new Request(session, "me/feed", postParams,
HttpMethod.POST, callback);
task = new RequestAsyncTask(request);
task.execute();
}
}
private void getFrdList() {
Session session = Session.getActiveSession();
if (session != null) {
GeneralClass.showToast("Wait while we get List",
getApplicationContext());
// Check for publish permissions
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONSFRD, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(
this, PERMISSIONSFRD);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
new Request(
session,
"/me/friends",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
JSONObject graphResponse = response.getGraphObject()
.getInnerJSONObject();
Log.e("JSON RESPONSE---->", "FRIEND LIST--->"+ graphResponse.toString());
}
}).executeAsync();
}
}
#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);
}
#Override
public void onBackPressed() {
// TODO Auto-generated method stub
if (isShareProcess == false) {
if (task != null) {
// Log.e("back press", "wait for share");
} else {
task = null;
// Log.e("back press", "no wait for share");
super.onBackPressed();
}
}
}
}
above code is displaying following output when click on friends button:
FRIEND LIST--->{"summary":{"total_count":10},"data":[]}
i dont know how to get list of friends. i already did R&D for this. but nothing getting actual result. i know in latest sdk, its not possible to get all friends but only those who used your app. i also try to run my app with two different users who are both friends. but still not getting in result.
kindly help me in this problem.
Since v2.0, it is not possible to get a list of ALL friends anymore. You will only get those friends who authorized your App too. That is why "data" is empty.
See the changelog for more information: https://developers.facebook.com/docs/apps/changelog
Check out the large amount of other threads about that exact same issue too, especially this one offers additional information: Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app

Facebook for Android: Session an attempt was made to request new permissions for a session

I'm new to FB SDK for android. I followed the sample tutorials as is. But I'm getting this error:
This is the code for MainFragment.class:
private static final String TAG = "MainFragment";
private UiLifecycleHelper uiHelper;
private TextView userInfoTextView;
private Button shareButton;
private static final List<String> PERMISSIONS = Arrays.asList("publish_actions");
private static final String PENDING_PUBLISH_KEY = "pendingPublishReauthorization";
private boolean pendingPublishReauthorization = false;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.activity_main, container, false);
LoginButton authButton = (LoginButton) view.findViewById(R.id.authButton);
authButton.setFragment(this);
if (savedInstanceState != null) {
pendingPublishReauthorization =
savedInstanceState.getBoolean(PENDING_PUBLISH_KEY, false);
}
authButton.setReadPermissions(Arrays.asList("user_location", "user_birthday", "email"));
// This opens a webview to type your email/username and password
//authButton.setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO);
userInfoTextView = (TextView) view.findViewById(R.id.userInfoTextView);
shareButton = (Button) view.findViewById(R.id.shareButton);
shareButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
publishStory();
}
});
return view;
}
private String buildUserInfoDisplay(GraphUser user) {
StringBuilder userInfo = new StringBuilder("");
// Example: typed access (name)
// - no special permissions required
userInfo.append(String.format("Name: %s\n\n",
user.getName()));
// Example: typed access (birthday)
// - requires user_birthday permission
userInfo.append(String.format("Firstname: %s\n\n",
user.getInnerJSONObject() ));
userInfo.append(String.format("Username: %s\n\n",
user.getUsername()));
userInfo.append(String.format("ID: %s\n\n",
user.getId()));
userInfo.append(String.format("Email: %s\n\n",
user.asMap().get("email")));
userInfo.append(String.format("Gender: %s\n\n",
user.asMap().get("gender") ));
return userInfo.toString();
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uiHelper = new UiLifecycleHelper(getActivity(), callback);
uiHelper.onCreate(savedInstanceState);
}
#Override
public void onResume() {
super.onResume();
uiHelper.onResume();
// For scenarios where the main activity is launched and user
// session is not null, the session state change notification
// may not be triggered. Trigger it if it's open/closed.
Session session = Session.getActiveSession();
if (session != null &&
(session.isOpened() || session.isClosed()) ) {
onSessionStateChange(session, session.getState(), null);
}
uiHelper.onResume();
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data);
}
#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);
outState.putBoolean(PENDING_PUBLISH_KEY, pendingPublishReauthorization);
uiHelper.onSaveInstanceState(outState);
}
//private boolean isLoggedIn = false; // by default assume not logged in
#SuppressWarnings("deprecation")
private void onSessionStateChange(Session session, SessionState state, Exception exception) {
if (state.isOpened()) {
Log.i(TAG, "Logged in...");
//isLoggedIn = true;
userInfoTextView.setVisibility(View.VISIBLE);
shareButton.setVisibility(View.VISIBLE);
if (pendingPublishReauthorization &&
state.equals(SessionState.OPENED_TOKEN_UPDATED)) {
pendingPublishReauthorization = false;
publishStory();
}
// Request user data and show the results
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
#Override
public void onCompleted(GraphUser user, Response response) {
// Display the parsed user info
userInfoTextView.setText(buildUserInfoDisplay(user));
}
});
} else if (state.isClosed()) {
Log.i(TAG, "Logged out...");
//isLoggedIn = false;
userInfoTextView.setVisibility(View.INVISIBLE);
shareButton.setVisibility(View.INVISIBLE);
}
}
private void publishStory() {
Session session = Session.getActiveSession();
if (session != null){
// Check for publish permissions
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session
.NewPermissionsRequest(this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
Bundle postParams = new Bundle();
postParams.putString("name", "Facebook SDK for Android");
postParams.putString("caption", "Build great social apps and get more installs.");
postParams.putString("description", "The Facebook SDK for Android makes it easier and faster to develop Facebook integrated Android apps.");
postParams.putString("link", "https://developers.facebook.com/android");
postParams.putString("picture", "https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");
Request.Callback callback= new Request.Callback() {
public void onCompleted(Response response) {
JSONObject graphResponse = response
.getGraphObject()
.getInnerJSONObject();
String postId = null;
try {
postId = graphResponse.getString("id");
} catch (JSONException e) {
Log.i(TAG,
"JSON error "+ e.getMessage());
}
FacebookRequestError error = response.getError();
if (error != null) {
Toast.makeText(getActivity()
.getApplicationContext(),
error.getErrorMessage(),
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getActivity()
.getApplicationContext(),
postId,
Toast.LENGTH_LONG).show();
}
}
};
Request request = new Request(session, "me/feed", postParams,
HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
}
}
private boolean isSubsetOf(Collection<String> subset, Collection<String> superset) {
for (String string : subset) {
if (!superset.contains(string)) {
return false;
}
}
return true;
}
private Session.StatusCallback callback = new Session.StatusCallback() {
#Override
public void call(Session session, SessionState state, Exception exception) {
onSessionStateChange(session, state, exception);
}
};
I just checked all the questions here on StackOverflow similar to mine but I didn't find one that solves my problem. Any ideas? I would gladly appreciate your help. Thanks.
This is an Old version (Deprecated). And the problem you were facing is , You already started a session and you were requesting a new session. Try the following sample(without deprecations) this might help you.
In OnResume() I mentioned Session session = Session.getActiveSession(); which gets the active session instead of requesting a new one. This might solve your problem of session management.
package com.example.integration;
import java.util.Arrays;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import com.facebook.Request;
import com.facebook.Response;
import com.facebook.Session;
import com.facebook.SessionState;
import com.facebook.model.GraphUser;
import com.facebook.widget.LoginButton;
public class MainActivity extends Activity {
private LoginButton fbLoginBtn;
private SharedPreferences mPrefs;
private Session.StatusCallback callback = new Session.StatusCallback() {
#Override
public void call(final Session session, final SessionState state, final Exception exception) {
onSessionStateChange(session, state, exception);
}
};
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
fbLoginBtn = (LoginButton) findViewById(R.id.fb_login_button);
fbLoginBtn.setReadPermissions(Arrays.asList("email"));
mPrefs = getPreferences(MODE_PRIVATE);
}
#Override
public void onResume() {
super.onResume();
Session session = Session.getActiveSession();
if (session != null &&
(session.isOpened() || session.isClosed()) ) {
onSessionStateChange(session, session.getState(), null);
}
}
private void onSessionStateChange(final Session session, SessionState state, Exception exception) {
if (state.isOpened()) {
Editor edit = mPrefs.edit();
edit.putString("access_token", session.getAccessToken());
edit.putString("expires", session.getExpirationDate() + "");
edit.commit();
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
#Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
String firstName = user.getFirstName();
String lastName = user.getLastName();
String id = user.getId();
String email = (String) user.asMap().get("email");
Log.i("facebookid", id);
Log.i("firstName", firstName);
Log.i("lastName", lastName);
Log.i("AccessToken", session.getAccessToken());
Log.i("Email", email);
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
intent.putExtra("name", firstName);
startActivity(intent);
}
}
});
}
else if (state.isClosed()) {
Toast.makeText(this, "Please Login", Toast.LENGTH_SHORT).show();
}
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(MainActivity.this, requestCode, resultCode, data);
}
}

facebook Post on your behalf is not working in android facebook sdk 3.0.2

i am try to share the post in facebook. login, publish permission is working finefor the first time. if i delete the app from facebook web it is not asking me reinstalling login and "Post on your behalf" publish permission screen below is my code Please help what i made mistike. I tried lot but is not working properly.. Thank you for your kind advice and so i can improve lot in android. Below is my code...
public class FacebokView extends Activity {
static final String applicationId = String.valueOf(R.string.app_id);
Session session;
private static final List<String> PERMISSIONS = Arrays.asList("publish_actions");
private static final String PENDING_PUBLISH_KEY = "pendingPublishReauthorization";
private boolean pendingPublishReauthorization = false;
private UiLifecycleHelper uiHelper;
//private StatusCallback statusCallback;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.faceok_view);
// create the session
this.session = createSession();
Log.i("session1--->", "session"+ session.isOpened());
// start Facebook Login
//Session.openActiveSession(this, true, new Session.StatusCallback() {
StatusCallback statusCallback = new StatusCallback() {
// callback when session changes state
#Override
public void call(Session session, SessionState state, Exception exception) {//READ
onSessionStateChange(session, state, exception);
Log.i("OPENED_TOKEN_UPDATED", state.equals(SessionState.OPENED_TOKEN_UPDATED) + "<<test");
if (session.isOpened() && session.getPermissions().contains("publish_actions")) {
Log.i("fb session1: publish_actions else if", session.getPermissions().contains("publish_actions") +"OPENED_TOKEN_UPDATED ----"+state.equals(SessionState.OPENED_TOKEN_UPDATED));
publishStory();
Log.i("session2--->", "session"+ session.isOpened());
} else if (session.isOpened()) {
Log.i("session3--->", "session"+ session.isOpened());
Log.i("fb session2: publish_actions else if", session.getPermissions().contains("publish_actions") +"OPENED_TOKEN_UPDATED ----"+state.equals(SessionState.OPENED_TOKEN_UPDATED));
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(FacebookView.this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
}
} else if(session != null && session.getState() == SessionState.CLOSED_LOGIN_FAILED){
Log.i("fb session:", "not open");
Log.i("session4--->", "session"+ session.isOpened());
finish();
}
}
};
if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)){
Log.i("session5--->", "session"+ session.isOpened());
session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
Log.i("CREATED_TOKEN_LOADED", "session"+ session.isOpened());
}else if (!session.isOpened() && !session.isClosed()) {
Log.i("session6--->", "session"+ session.isOpened());
OpenRequest req = new Session.OpenRequest(this);
req.setCallback(statusCallback);
session.openForRead(req);
} else {
Log.i("session7--->", "session"+ session.isOpened());
Session.openActiveSession(this, true, statusCallback);
}
}
private void onSessionStateChange(Session session, SessionState state,Exception exception) {
if (state.isOpened()) {
if (pendingPublishReauthorization && state.equals(SessionState.OPENED_TOKEN_UPDATED)) {
Log.i("onSessionStateChange--->OPENED_TOKEN_UPDATED -->", state.equals(SessionState.OPENED_TOKEN_UPDATED) + "pendingPublishReauthorization-->" + pendingPublishReauthorization);
pendingPublishReauthorization = false;
publishStory();
Log.i("session12--->", "session"+ session.isOpened());
}
} else if (state.isClosed()) {
Log.i("session8--->", "session"+ session.isOpened());
// shareButton.setVisibility(View.INVISIBLE);
}
}
protected void publishStory() {
Session session = Session.getActiveSession();
if (session != null){
// Check for publish permissions
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
// after login make request to the /me API
Bundle parameters = getIntent().getExtras();
String facebookResponse = parameters.getString("facebookResponse");
Log.i("fbResp from server 1 publish_actions:", session.getPermissions().contains("publish_actions") + "*---facebookResponse----*"+ facebookResponse);
try {
JSONObject jsonObj = new JSONObject(facebookResponse);
parameters.putString("message", jsonObj.getString("MsgForFb"));
parameters.putString("name", jsonObj.getString("NameForFb"));
parameters.putString("link", jsonObj.getString("LinkForFb"));
parameters.putString("Description", jsonObj.getString("DescForFb"));
parameters.putString("picture", jsonObj.getString("PicForFb"));
} catch (JSONException e1) {
e1.printStackTrace();
}
Request.Callback callback = new Request.Callback() {
public void onCompleted(Response response) {
if(response.getGraphObject() != null) {
Log.i("fb Response - ", response.toString());
JSONObject graphResponse = response.getGraphObject().getInnerJSONObject();
String postId = null;
try {
postId = graphResponse.getString("id");
} catch (JSONException e) {
e.printStackTrace();
Log.e("FacebookView: callBack:", "JSON error : " + e.getMessage());
}
FacebookRequestError error = response.getError();
if (error != null) {
Toast.makeText(FacebookView.this.getApplicationContext(), error.getErrorMessage(), Toast.LENGTH_LONG).show();
} else {
Log.i("FacebookView: Request.Callbak: postId = ", " "+postId);
}
}
}
};
Request request = new Request(session, "me/feed", parameters, HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
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) {
finish();
}
}
});
}
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
private Session createSession() {
Session activeSession = Session.getActiveSession();
if (activeSession == null || activeSession.getState().isClosed()) {
activeSession = new Session.Builder(this).setApplicationId(applicationId).build();
Session.setActiveSession(activeSession);
}
return activeSession;
}
private boolean isSubsetOf(Collection<String> subset, Collection<String> superset) {
for (String string : subset) {
if (!superset.contains(string)) {
return false;
}
}
return true;
}
}
If the user deletes the app from Facebook, the only way your app will know is if you make a graph request, and it fails.
Here are some common strategies for handling errors - https://developers.facebook.com/docs/reference/api/errors/
You should also have a look at the Scrumptious sample that ships with the SDK, there's a handleError() method in SelectionFragment.java that implements the strategies outlined in the link above.

publishing on facebook with sdk 3.0 and android doesn't work

I set a connection to fb in my app: clicking a button the app does the login, posts on the wall and then does logout. Everything works perfect for me with my developer account, but trying with other phones and other accounts, if official FB app is installed, the app doesn't publish anything. I have just changed key-hash, i didn't use debug.keystore but a new keystore..... Anyone can help me????
Thank you very much!
i followed tutorials from fb, this is my login method
private void onClickLogin() {
Session session = Session.getActiveSession();
login=true;
if (session!=null && !session.isOpened() && !session.isClosed()) {
session.openForPublish(new Session.OpenRequest(this)
.setPermissions(Arrays.asList("publish_actions"))
.setCallback(callback));
} else {
Session.openActiveSession(getActivity(), this, true, callback);
}
}
this is all the "interesting" code
boolean login= false;
private Session.StatusCallback callback = new Session.StatusCallback() {
#Override
public void call(Session session, SessionState state, Exception exception) {
onSessionStateChange(session, state, exception);
}
};
private UiLifecycleHelper uiHelper;
private static final List<String> PERMISSIONS = Arrays.asList("publish_actions");
private static final String PENDING_PUBLISH_KEY = "pendingPublishReauthorization";
private boolean pendingPublishReauthorization = false;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uiHelper = new UiLifecycleHelper(getActivity(), callback);
uiHelper.onCreate(savedInstanceState);
}
public void setEnt(Entry e) {
art=e;
}
#Override
public void onResume() {
super.onResume();
Session session = Session.getActiveSession();
uiHelper.onResume();
}
#Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data);
}
#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);
}
private void onClickLogin() {
Session session = Session.getActiveSession();
login=true;
if (session!=null && !session.isOpened() && !session.isClosed()) {
session.openForPublish(new Session.OpenRequest(this)
.setPermissions(Arrays.asList("publish_actions"))
.setCallback(callback));
} else {
Session.openActiveSession(getActivity(), this, true, callback);
}
}
private void onSessionStateChange(Session session, SessionState state, Exception exception) {
if (state.isOpened()) {
publishStory();
} else if (state.isClosed()) {
}
}
private void publishStory() {
Session session = Session.getActiveSession();
if(login){
if (session != null){
Bundle postParams = new Bundle();
postParams.putString("name", art.getTitle());
postParams.putString("caption", art.getSection());
postParams.putString("description", "xxx");
postParams.putString("link", "xxx");
postParams.putString("picture", "xxx");
Request.Callback callback= new Request.Callback() {
public void onCompleted(Response response) {
JSONObject graphResponse = response.getGraphObject().getInnerJSONObject();
String postId = null;
try {
postId = graphResponse.getString("id")+" articolo postato";
} catch (JSONException e) {
Log.i(TAG,
"JSON error "+ e.getMessage());
}
FacebookRequestError error = response.getError();
if (error != null) {
Toast.makeText(getActivity()
.getApplicationContext(),
error.getErrorMessage(),
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getActivity()
.getApplicationContext(),
postId,
Toast.LENGTH_LONG).show();
logout();
}
}
};
Request request = new Request(session, "me/feed", postParams,
HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
Log.v("FB", "FINE");
}
}
}
private void logout(){
login=false;
if (Session.getActiveSession() != null) {
Session.getActiveSession().closeAndClearTokenInformation();
}
Session.setActiveSession(null);
}
private boolean isSubsetOf(Collection<String> subset, Collection<String> superset) {
for (String string : subset) {
if (!superset.contains(string)) {
return false;
}
}
return true;
}
}
I think that your app may be placed in the sandbox mode and which is what causing others not from accessing your app. You may be the admin of the app and with your account you can access the app even in sandbox mode
So disable it to make your app work for others.
Also check whether you have added the keyhash generated using your keystore file
Turn-off the sandbox mode in your App settings.
Click here to go to your App Dashboard

android error with facebook login on market

When i test this app on my device with eclipse is all ok;but when i publish this app on google play store the facebook login failed!!
why?
help me please!!
it is a simply app ("coffee break" on market);
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main );
elementoInserito=(EditText)findViewById(R.id.editTextElementoInserito);
elementoEstratto=(TextView)findViewById(R.id.textViewElementoEstratto);
inserisci=(Button)findViewById(R.id.buttonInserisci);
stampa=(Button)findViewById(R.id.buttonStampa);
facebookLogin=(Button)findViewById(R.id.facebookLogin);
Session session = Session.getActiveSession();
if (session == null) {
if (savedInstanceState != null) {
session =Session.restoreSession(this,null,statusCallback,savedInstanceState);
}
if (session == null) {
session = new Session(this);
}
Session.setActiveSession(session);
if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) {
session.openForRead(newSession.OpenRequest(this).setCallback(statusCallback));
}
}
inserisci.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
inizializza_array(elementoInserito);
elementoInserito.setText("");
}
});
updateView();
}
private void updateView() {
Session session = Session.getActiveSession();
if (session.isOpened()) {
facebookLogin.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
onClickLogout(); }
});
}
else {
facebookLogin.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
onClickLogin(); }
});
}
}
private void onClickLogin() {
Session session = Session.getActiveSession();
if (!session.isOpened() && !session.isClosed()) {
session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
} else {
Session.openActiveSession(this, true, statusCallback);
}
Bundle bundle=new Bundle();
Session.saveSession(session,bundle);
Toast.makeText(getApplicationContext(),
"sto salvando la sessione "+session.getState(),
Toast.LENGTH_LONG).show();
}
private void onClickLogout() {
Session session = Session.getActiveSession();
if (!session.isClosed()) {
session.closeAndClearTokenInformation();
}
}
private class SessionStatusCallback implements Session.StatusCallback {
#Override
public void call(Session session, SessionState state, Exception exception) {
onSessionStateChange(session, state, exception);
updateView();
}
}
private void onSessionStateChange(Session session, SessionState state, Exception exception) {
if (state.isOpened()) {
Log.i(TAG, "Logged in...");
} else if (state.isClosed()) {
Log.i(TAG, "Logged out...");
}
}
public void inizializza_array(EditText n){
this.ins=""+n.getText();
if(ins==""){
Toast.makeText(getApplicationContext(),
"errore: campo vuoto",
Toast.LENGTH_LONG).show();
}
else{
lista.add(ins);
}
}
public void stampa(View v){
if(lista.size()==0){
elementoEstratto.setText("Inserire elementi");
}
else{
Random random = new Random();
String x = lista.get(random.nextInt(lista.size()));
elementoEstratto.setText(x);
lista.clear();
try {
publishStory(x);
} catch (Exception e) {
}
}
}
public void onStart() {
super.onStart();
Session.getActiveSession().addCallback(statusCallback);
}
#Override
public void onStop() {
super.onStop();
Session.getActiveSession().removeCallback(statusCallback);
}
#Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Session session = Session.getActiveSession();
Session.saveSession(session, outState);
}
public void publishStory(String sorteggiato) {
Session session = Session.getActiveSession();
try {
if (session != null){
List<String> permissions = session.getPermissions();
if (!isSubsetOf(PERMISSIONS, permissions)) {
pendingPublishReauthorization = true;
Session.NewPermissionsRequest newPermissionsRequest = new Session
.NewPermissionsRequest(this, PERMISSIONS);
session.requestNewPublishPermissions(newPermissionsRequest);
return;
}
Bundle postParams = new Bundle();
postParams.putString("name",""));
postParams.putString("caption","");
postParams.putString("description","");
Request.Callback callback= new Request.Callback() {
public void onCompleted(Response response) {
JSONObject graphResponse = response
.getGraphObject()
.getInnerJSONObject();
String postId = null;
try {
postId = graphResponse.getString("id");
} catch (JSONException e) {
Log.i(TAG,
"JSON error "+ e.getMessage());
}
FacebookRequestError error = response.getError();
if (error != null) {
Toast.makeText(getApplicationContext(),
error.getErrorMessage(),
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(),
"shared",//postId
Toast.LENGTH_LONG).show();
}
}
};
Request request = new Request(session, "me/feed", postParams,
HttpMethod.POST, callback);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
}
else{
Toast.makeText(getApplicationContext(),
"effettua il Login su Facebook per condividere con i tuo amici",
Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
// TODO: handle exception
}
}
private boolean isSubsetOf(Collection<String> subset, Collection<String> superset) {
for (String string : subset) {
if (!superset.contains(string)) {
return false;
}
}
return true;
}
#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) {
Intent intent = new Intent (MainActivity.this,Info.class);
//Intent intent2 = new Intent(MainActivity.this,Caffe.class);
menu.add("About Coffee Break").setIntent(intent);
//menu.add("Il caffè").setIcon(R.drawable.caffe).setIntent(intent2);
return true;
}
}
i don't understand why i've this problem
i've self resolved the problem, i did not read the relese.keystore in the rigth way
I did not understand this code:
keytool -exportcert -alias myAlias -keystore ~/.your/path/release.keystore | openssl sha1 -binary | openssl base64
when I realized the code I got the right key
myAlias = alis used when i export the project
~/.your/path/release.keystore = the path where the key generated from eclipse is located, and the name of the file
Good Job

Categories

Resources