In My Application i am Using the Below Code to Uploade the Photo.
While i am unistalling the application and reinstall the application and posting thehoto on the facebook and if the faceboook id is new then it gives me the screen of application allow access. but Some time it not gives me that screen. I dont know whats the problem in it.
Please see the code and give me the Sollution. Why i am not able to get the application allow access Screen. Thanks.
the Code is:
// For Facebook ===================================
Button facebookButton = (Button) saveButtonDialog.findViewById(R.id.facebook);
facebookButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
saveButtonDialog.dismiss();
saveImageFunction(); // to save the Image
facebook.authorize(TWSBIDrawMainActivity.this, new String[]{ "user_photos,publish_checkins,publish_actions,publish_stream"},new DialogListener() {
@Override
public void onComplete(Bundle values) {
postImageonWall();
Toast.makeText(getApplicationContext(), "Image Posted on Facebook.", Toast.LENGTH_SHORT).show();
//File f = new File(APP_FILE_PATH + "/"+filename+".jpg");
//f.delete();
}
@Override
public void onFacebookError(FacebookError error) {
}
@Override
public void onError(DialogError e) {
}
@Override
public void onCancel() {
}
});
}
});
public void postImageonWall() {
byte[] data = null;
Bitmap bi = BitmapFactory.decodeFile(APP_FILE_PATH + "/"+filename+".jpg");
//Bitmap bi = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bi.compress(Bitmap.CompressFormat.JPEG, 100, baos);
data = baos.toByteArray();
Bundle params = new Bundle();
params.putString(Facebook.TOKEN, facebook.getAccessToken());
params.putString("method", "photos.upload");
params.putByteArray("picture", data);
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
mAsyncRunner.request(null, params, "POST", new SampleUploadListener(), null);
}