Java 新的Facebook SDK+;安卓在facebook上添加图片
我找不到一个有效的方法把照片挂在墙上。 我的代码是我不知道Java 新的Facebook SDK+;安卓在facebook上添加图片,java,android,facebook,image,facebook-wall,Java,Android,Facebook,Image,Facebook Wall,我找不到一个有效的方法把照片挂在墙上。 我的代码是我不知道 Bundle postParams = new Bundle(); postParams.putByteArray("image", byteArray); postParams.putString("message", "A wall picture"); Session session = Session.getActiveSession(); if (session != null) {
Bundle postParams = new Bundle();
postParams.putByteArray("image", byteArray);
postParams.putString("message", "A wall picture");
Session session = Session.getActiveSession();
if (session != null) {
Log.e("Session", "don t null");
Request request = new Request(session, "me/feed", postParams,
HttpMethod.POST);
RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();
我从来没有通过手机发送过图片,而是通过图像链接从服务器发送的。我将把这段代码放在它对您有帮助的情况下,因为大多数逻辑是相似的
final Bundle parameters = new Bundle();
parameters.putString("name", getString(R.string.app_name));
parameters.putString("caption", "haha");
parameters.putString("link", "www.google.com");
parameters.putByteArray("picture", byteArray);//I took this one from your code. My key is "picture" instead of "image"
Session.openActiveSession(this, true, new StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
new FeedDialogBuilder(EndGameActivity.this, session, parameters).build().show();
//you can try this one instead of the one above if you want, but both work well
//Request.newMeRequest(session, new Request.GraphUserCallback() {
//
// @Override
// public void onCompleted(GraphUser user, Response response) {
// final Session session = Session.getActiveSession();
// new FeedDialogBuilder(EndGameActivity.this, session, parameters).build().show();
// }
//}).executeAsync();
}
}
});
此代码仅在最近推出的Request.newMeRequest
之后的最后一个Facebook SDK 3.5中有效,应该使用它来代替已被弃用的Request.executeRequestAsync
还要注意,我使用的键是“picture”而不是“image”。也许这就是你的代码的问题
但是当用户触摸按钮时,我会在一个
onClick
事件中执行此操作。为什么在onCreate
方法中需要它 这是在OnCreate中完成的。在经历了这些之后,我确实像示例中那样进行了授权。我有一个用户名。但是我不能发照片。”代码'Session.openActiveSession(这是真的,新Session.StatusCallback(){…}是的..我认为使用手机图片不是一个好的做法