このコードを使用して、画像を Facebook に投稿しました。しかし、このコードからの応答はありません。私を助けてください。
//I had created onCreate() method as :
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
facebook = new Facebook(APP_ID);
restoreCredentials(facebook);
//requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
postToWall();
}
//このコードを postToWall() に使用: このメソッドでは、投稿する画像のパスを指定し、//このメソッドは onCreate() で呼び出しています。
プライベートボイドpostToWall(){
FileInputStream fis = null;
try {
fis = new FileInputStream("/mnt/sdcard/Blue_Dock_by_dimage.jpg");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 2;
Bitmap bm = BitmapFactory.decodeStream(fis);
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 100, stream); // where bm is bitmap from Sdcard
byte[] byteArray = stream.toByteArray();
Bundle param = new Bundle();
param = new Bundle();
param.putString("message", "All");
param.putString("filename", "TEst");
param.putByteArray("image", byteArray);
mAsyncRunner.request("me/photos", param, "POST", new fbRequestListener(), null);
}
//このコードを fbRequestListener() クラスに使用:
public class fbRequestListener は RequestListener を実装します {
public void onComplete(String response, Object state) {
// TODO Auto-generated method stub
Log.d("RESPONSE",""+response);
}
public void onIOException(IOException e, Object state) {
// TODO Auto-generated method stub
Log.d("RESPONSE",""+e);
showToast("Authentication with Facebook failed!");
finish();
}
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
// TODO Auto-generated method stub
Log.d("RESPONSE",""+e);
showToast("Authentication with onFileNotFoundException failed!");
finish();
}
public void onMalformedURLException(MalformedURLException e,
Object state) {
// TODO Auto-generated method stub
showToast("Authentication with onMalformedURLException!");
finish();
}
public void onFacebookError(FacebookError e, Object state) {
// TODO Auto-generated method stub
Log.d("RESPONSE",""+e);
showToast("Authentication with onFacebookError failed!");
finish();
}
}