这个问题可能看起来很相似,但与“使用 Facebook sdk 在 Facebook 上共享视频”或“使用共享意图共享纯文本或图像”没有任何关系。我在 SO -> 上关注了这些帖子
如何在 Facebook 上通过 Android 分享意图与 CAPTION 分享照片?
和这个外部链接
http://sudarmuthu.com/blog/sharing-content-in-android-using-action_send-intent
并了解了android中的共享意图,可以启动它与Android手机上现有的共享应用程序共享图像/视频/文本。我使用此代码在 facebook 上共享图像:
package com.mypackage.share;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
public class FbshareActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpg");
share.putExtra(Intent.EXTRA_STREAM,Uri.parse("file:///mnt/sdcard/tutu.jpg"));
startActivity(Intent.createChooser(share, "Share Image"));
}
}
清单文件如下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mypackage.share"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".FbshareActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
它工作正常。我可以在 facebook 上分享图像。
现在我想上传视频:我替换了这一行: share.setType("image/jpg");
用这个
share.setType("video/3gpp");
和这个
share.putExtra(Intent.EXTRA_STREAM,Uri.parse("**file:///mnt/sdcard/dimg1333456357958.jpg "));** 和这个
share.putExtra(Intent.EXTRA_STREAM,Uri.parse ("**file:///mnt/sdcard/a123bghy4.3gpp "));**
但是我在运行代码时遇到了这个错误:
/Environment(30996): getExternalStorageState/mnt/sdcard
E/Environment(30996): getExternalStorageList
W/MountService( 2879): getVolumeState(/mnt/sdcard/external_sd): Unknown volume
W/MountService( 2879): getVolumeState(/mnt/sdcard/external_sd): Unknown volume
E/Environment(30996): getExternalStorageState/mnt/sdcard
D/SurfaceFlinger( 2879): [JJ]removeSurface for sid=74
D/dalvikvm(30996): GC_CONCURRENT freed 1106K, 19% free 8612K/10503K, paused 3ms+5ms
E/SurfaceFlinger( 2879): [JJ]SurfaceFlinger FPS: 24.994677
D/ACRA (30996): Writing crash report file.
D/ACRA (30996): Mark all pending reports as approved.
D/ACRA (30996): Looking for error files in /data/data/com.facebook.katana/app_acra-reports
V/ACRA (30996): About to start ReportSenderWorker from #handleException
D/ACRA (30996): Add user comment to null
D/ACRA (30996): #checkAndSendReports - start
D/ACRA (30996): Looking for error files in /data/data/com.facebook.katana/app_acra-reports
I/ACRA (30996): Sending file 1333628258000-approved.stacktrace
D/ACRA (30996): Connect to https://www.facebook.com/mobile/android_crash_logs/
D/ACRA (30996): Setting httpPost headers
D/ACRA (30996): Sending request to https://www.facebook.com/mobile/android_crash_logs/
D/dalvikvm(30996): GC_CONCURRENT freed 631K, 18% free 8644K/10503K, paused 5ms+2ms
W/ResponseProcessCookies(30996): Invalid cookie header: "Set-Cookie: datr=ZY19T4_v6CV68jQn4FTduX_l; expires=Sat, 05-Apr-2014 12:17:41 GMT; path=/; domain=.facebook.com; httponly". Unable to parse expires attribute: Sat
E/SurfaceFlinger( 2879): [JJ]SurfaceFlinger FPS: 4.741684
D/BatteryService( 2879): update start
D/ACRA (30996): #checkAndSendReports - finish
E/AndroidRuntime(30996): FATAL EXCEPTION: main
E/AndroidRuntime(30996): java.lang.NullPointerException
E/AndroidRuntime(30996): at com.facebook.katana.service.method.VideoUpload.getRealPathFromURI(VideoUpload.java:144)
E/AndroidRuntime(30996): at com.facebook.katana.service.method.VideoUpload.start(VideoUpload.java:165)
E/AndroidRuntime(30996): at com.facebook.katana.binding.AppSession.postToService(AppSession.java:4212)
E/AndroidRuntime(30996): at com.facebook.katana.service.method.VideoUpload.RequestVideoUpload(VideoUpload.java:73)
E/AndroidRuntime(30996): at com.facebook.katana.activity.media.UploadVideoActivity.upload(UploadVideoActivity.java:209)
E/AndroidRuntime(30996): at com.facebook.katana.activity.media.UploadVideoActivity.onClick(UploadVideoActivity.java:169)
E/AndroidRuntime(30996): at android.view.View.performClick(View.java:3100)
E/AndroidRuntime(30996): at android.view.View$PerformClick.run(View.java:11644)
E/AndroidRuntime(30996): at android.os.Handler.handleCallback(Handler.java:587)
E/AndroidRuntime(30996): at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime(30996): at android.os.Looper.loop(Looper.java:126)
E/AndroidRuntime(30996): at android.app.ActivityThread.main(ActivityThread.java:4002)
E/AndroidRuntime(30996): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(30996): at java.lang.reflect.Method.invoke(Method.java:491)
E/AndroidRuntime(30996): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
E/AndroidRuntime(30996): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
E/AndroidRuntime(30996): at dalvik.system.NativeStart.main(Native Method)
D/SurfaceFlinger( 2879): screenshot: sw=216, sh=135, minZ=0, maxZ=21015
W/ActivityManager( 2879): Force finishing activity com.facebook.katana/.activity.media.UploadVideoActivity
D/SurfaceFlinger( 2879): screenshot: result = OK
E/android.os.Debug( 2879): Dumpstate > /data/log/dumpstate_app_com_facebook_katana_error
I/dumpstate(31581): begin
W/ActivityManager( 2879): Activity pause timeout for ActivityRecord{40f51e68 com.facebook.katana/.activity.media.UploadVideoActivity}
F//system/bin/logcat(31586): stack corruption detected: aborted
W/PowerManagerService( 2879): Timer 0x3->0x3|0x0
D/VoldCmdListener( 87): asec list
I/dumpstate(31581): done
D/InputTransport( 2879): channel '41014710 Sorry! - Use *#9900# to take log - (server)' ~ mPointerStates->semaphore initialized 0x586ac000.
D/InputTransport( 2879): channel '41014710 Sorry! - Use *#9900# to take log - (server)' ~ mPointerStates initialized 0x586ac000.
D/InputTransport( 2879): channel '41014710 Sorry! - Use *#9900# to take log - (client)' ~ mPointerStates initialized 0x587f1000.
E/SurfaceFlinger( 2879): [JJ]SurfaceFlinger FPS: 0.207880
D/SurfaceFlinger( 2879): [JJ]createSurface for pid 31559 (1280 x 752)
D/SurfaceFlinger( 2879): [JJ]createSurface for pid 2879 (1 x 1)
E/SurfaceFlinger( 2879): [JJ]SurfaceFlinger FPS: 18.909105
我如何调试 com.facebook.katana ?请帮忙。Rgds