1
我想從我的Android應用程序共享圖像到Facebook使用Facebook SDK.I有一個按鈕命名共享在我的app.when我點擊該按鈕應該在Facebook上分享我的設備上的圖像。這裏的問題是當我點擊按鈕Facebook登錄頁面打開,但成功登錄Facebook後將關閉和圖像不共享。 任何人都可以建議我,我在哪裏做錯了?如何使用Facebook SDK for Android在Facebook上分享圖片?
FacebookSdk.sdkInitialize(getActivity());
callbackManager = CallbackManager.Factory.create();
List<String> permissionNeeds = Arrays.asList("publish_actions");
//this loginManager helps you eliminate adding a LoginButton to your UI
manager = LoginManager.getInstance();
manager.logInWithPublishPermissions(getActivity(), permissionNeeds);
manager.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Log.e("ShareMethod", "called");
sharePhotoToFacebook();
}
@Override
public void onCancel() {
System.out.println("onCancel");
}
@Override
public void onError(FacebookException exception) {
System.out.println("onError1234");
}
});
private void sharePhotoToFacebook(){
file1 = new File(path);
bitmap1 = BitmapFactory.decodeFile(file1.getAbsolutePath());
Log.e("Bitmap1",""+bitmap1);
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(bitmap1)
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
ShareApi.share(content, null);
Log.e("Sharing","Successful");
}
@Override
public void onActivityResult(int requestCode, int responseCode, Intent data)
{
super.onActivityResult(requestCode, responseCode, data);
callbackManager.onActivityResult(requestCode, responseCode, data);
}
我的Logcat輸出如下。
11-21 12:57:06.248 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000b44
11-21 12:57:06.269 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000bd0
11-21 12:57:06.276 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ **** ERROR unknown type 0x73000f (glSizeof,72)
11-21 12:57:08.582 1139-1171/com.example.omshiv.moviehub W/EGL_emulation﹕ eglSurfaceAttrib not implemented
11-21 12:57:08.582 1139-1171/com.example.omshiv.moviehub W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa0625d40, error=EGL_SUCCESS
11-21 12:57:08.598 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000b44
11-21 12:57:08.599 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000bd0
11-21 12:57:08.613 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ **** ERROR unknown type 0x73000f (glSizeof,72)
11-21 12:57:08.642 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000b44
11-21 12:57:08.650 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000bd0
11-21 12:57:08.664 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ **** ERROR unknown type 0x73000f (glSizeof,72)
11-21 12:57:08.688 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000b44
11-21 12:57:08.691 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000bd0
11-21 12:57:08.703 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ **** ERROR unknown type 0x73000f (glSizeof,72)
11-21 12:57:08.739 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000b44
11-21 12:57:08.740 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000bd0
11-21 12:57:08.762 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ **** ERROR unknown type 0x73000f (glSizeof,72)
11-21 12:57:08.776 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000b44
11-21 12:57:08.798 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000bd0
11-21 12:57:08.822 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ **** ERROR unknown type 0x73000f (glSizeof,72)
11-21 12:57:08.833 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000b44
11-21 12:57:08.867 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000bd0
11-21 12:57:08.901 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ **** ERROR unknown type 0x73000f (glSizeof,72)
11-21 12:57:08.905 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000b44
11-21 12:57:08.908 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000bd0
11-21 12:57:08.925 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ **** ERROR unknown type 0x73000f (glSizeof,72)
11-21 12:57:08.949 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000b44
11-21 12:57:08.950 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000bd0
11-21 12:57:08.953 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ **** ERROR unknown type 0x73000f (glSizeof,72)
11-21 12:57:09.079 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000b44
11-21 12:57:09.080 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000bd0
11-21 12:57:09.099 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ **** ERROR unknown type 0x73000f (glSizeof,72)
11-21 12:57:09.127 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000b44
11-21 12:57:09.129 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000bd0
11-21 12:57:09.152 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ **** ERROR unknown type 0x73000f (glSizeof,72)
11-21 12:57:09.155 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000b44
11-21 12:57:09.155 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000bd0
11-21 12:57:09.169 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ **** ERROR unknown type 0x73000f (glSizeof,72)
11-21 12:57:09.179 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000b44
11-21 12:57:09.199 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ glUtilsParamSize: unknow param 0x00000bd0
11-21 12:57:09.205 1139-1171/com.example.omshiv.moviehub E/eglCodecCommon﹕ **** ERROR unknown type 0x73000f (glSizeof,72)
你在分享時遇到任何錯誤嗎? –
成功登錄後,Facebook自動關閉,並且未調用sharePhotoToFacebook()方法。 –
一旦從Facebook帳戶應用設置中刪除應用,然後重試。 –