2014-02-17 84 views
0
Request request = Request.newUploadPhotoRequest(Session.getActiveSession(),mBitmap, new Request.Callback() {       
     @Override 
     public void onCompleted(Response response) { 
      savedBitmap = saveBitmapToStorage(); 
      if (response.getError() == null && savedBitmap != null) { 
       pd = ProgressDialog.show(ctx, ctx.getResources().getString(R.string.sys_info),ctx.getResources().getString(R.string.publishing)); 
       new APIHandler(ctx,tracker,"uploadImg").execute(ctx,shareTxt,savedBitmap,catId); 
      } else { 
       Log.d(TAG,response.getError().getErrorMessage()); 
       Toast.makeText(ctx, response.getError().getErrorMessage(), Toast.LENGTH_LONG).show(); 
       Utility.showDialog(ctx,"error",tracker,false); 
      } 
     } 
    }); 
    Bundle params = request.getParameters(); 
    shareTxt = shareContent.getText().toString() == "" ? getResources().getString(R.string.default_msg) : shareContent.getText().toString(); 
    params.putString("message", shareTxt); 
    params.putString("link", "https://developers.facebook.com/android"); 
    request.setParameters(params); 
    request.executeAsync(); 

在我的Facebook共享代碼中,我想與url共享圖像,但是,它不起作用,只有圖像和消息顯示在Facebook中,如何解決它?感謝如何在android facebook sdk中將圖片分享到圖庫中?

有一個警告,但我不知道它是否是相關

02-18 00:54:20.353: W/System.err(1062): android.view.WindowManager$BadTokenException: Unable to add window -- token [email protected] is not valid; is your activity running? 
02-18 00:54:20.353: W/System.err(1062):  at android.view.ViewRootImpl.setView(ViewRootImpl.java:662) 
02-18 00:54:20.353: W/System.err(1062):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:344) 
02-18 00:54:20.353: W/System.err(1062):  at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:228) 
02-18 00:54:20.353: W/System.err(1062):  at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:153) 
02-18 00:54:20.353: W/System.err(1062):  at android.view.Window$LocalWindowManager.addView(Window.java:586) 
02-18 00:54:20.353: W/System.err(1062):  at android.app.Dialog.show(Dialog.java:277) 
02-18 00:54:20.353: W/System.err(1062):  at android.app.ProgressDialog.show(ProgressDialog.java:116) 
02-18 00:54:20.353: W/System.err(1062):  at android.app.ProgressDialog.show(ProgressDialog.java:99) 
02-18 00:54:20.353: W/System.err(1062):  at android.app.ProgressDialog.show(ProgressDialog.java:94) 
02-18 00:54:20.353: W/System.err(1062):  at com.project.hkseven.Activity.SharePicForm$3.onCompleted(SharePicForm.java:263) 
02-18 00:54:20.353: W/System.err(1062):  at com.facebook.Request$4.run(Request.java:1669) 
02-18 00:54:20.353: W/System.err(1062):  at android.os.Handler.handleCallback(Handler.java:615) 
02-18 00:54:20.353: W/System.err(1062):  at android.os.Handler.dispatchMessage(Handler.java:92) 
02-18 00:54:20.353: W/System.err(1062):  at android.os.Looper.loop(Looper.java:137) 
02-18 00:54:20.353: W/System.err(1062):  at android.app.ActivityThread.main(ActivityThread.java:4882) 
02-18 00:54:20.353: W/System.err(1062):  at java.lang.reflect.Method.invokeNative(Native Method) 
02-18 00:54:20.353: W/System.err(1062):  at java.lang.reflect.Method.invoke(Method.java:511) 
02-18 00:54:20.363: W/System.err(1062):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) 
02-18 00:54:20.363: W/System.err(1062):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556) 
02-18 00:54:20.363: W/System.err(1062):  at dalvik.system.NativeStart.main(Native Method) 
02-18 00:54:20.704: W/dalvikvm(1062): threadid=1: thread exiting with uncaught exception (group=0x40f1f438) 
+1

你能否檢查logcat中是否有錯誤? –

回答

0

的Facebook SDK不會讓你在同一時間分享圖片和網址。如果它是圖片,則網址將被排除。如果您使用網址進行正常發佈,則會從網站中選擇圖片,並且無法將自定義圖片添加到該圖片上。希望這可以幫助。

0

只需將url添加到parms(「message」)即可。 facebook會自動處理

相關問題