привет первый Загрузить Facebook SDK ..
Facebook SDK
затем в методе Создать
// для Authonticaion
public class FacebollAppforPhotoUpload extends Activity {
//------------------FB-------------------------
Facebook facebook = new Facebook("APP_KEY");
String permissions[] = {""};
String statusString = "";
//---------------------------------------------
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
statusString="testing Post For Application Development";
setContentView(R.layout.main);
facebook.authorize(this, permissions, new DialogListener() {
@Override
public void onComplete(Bundle values) {
// updateStatus(values.getString(Facebook.TOKEN));
uploadphoto(values.getString(Facebook.TOKEN));
finish();
}
@Override
public void onFacebookError(FacebookError error) {}
@Override
public void onError(DialogError e) {}
@Override
public void onCancel() {
finish();
}
});
Способ загрузки фото
public void uploadphoto(String accessToken)
{
byte[] data = null;
ContentResolver cr = FacebollAppforPhotoUpload.this.getContentResolver();
// InputStream fis = cr.openInputStream(localSnapshotUri);
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("method", "photos.upload");
params.putByteArray("picture", data);
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
mAsyncRunner.request(null, params, "POST", new RequestListener(){
@Override
public void onComplete(String response, Object state) {
// TODO Auto-generated method stub
}
@Override
public void onIOException(IOException e, Object state) {
// TODO Auto-generated method stub
}
@Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
// TODO Auto-generated method stub
}
@Override
public void onMalformedURLException(MalformedURLException e,
Object state) {
// TODO Auto-generated method stub
}
@Override
public void onFacebookError(FacebookError e, Object state) {
// TODO Auto-generated method stub
}},null);
}