dimanche 1 mars 2015

Posting image from android app to facebook

i really need help, i'm developing android app where there is a part i can post image and videos to Facebook , my Facebook APP have the basic permissions (public_profile,email,user_friends) but before posting i'm requesting from publish_actions permission using this method :



public void requestPermissions() {
Session s = Session.getActiveSession();

if (s != null)
{
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(
this, PERMISSIONS);
s.requestNewPublishPermissions(newPermissionsRequest);
}


}


but it never show dialog for confirming this permission and hence the posting image is not working , here is my method:



// share on facebook
public synchronized void postImage(String imagePath) {

// change the image
//Bitmap img = BitmapFactory.decodeFile(recievedImageURI);
if(checkPermissions())
{
Bitmap image=BitmapFactory.decodeFile(imagePath);
Request uploadRequest = Request.newUploadPhotoRequest(
Session.getActiveSession(),image, new Request.Callback() {
@Override
public void onCompleted(Response response) {
// Toast.makeText(getApplicationContext(),
// "Photo uploaded successfully",
// Toast.LENGTH_LONG).show();
//showDailog2("Photo uploaded successfully");
Intent gotoShare=new Intent(getApplicationContext(), FlickerActivity.class);
startActivity(gotoShare);


}
});
uploadRequest.executeAsync();
FlickerActivity.uploadNext();

}
else
{
requestPermissions();
}


}

Aucun commentaire:

Enregistrer un commentaire