android无法将图像分享到LINE App

时间:2016-03-18 07:59:03

标签: android share

我有片段包含图像和按钮分享。我曾意图分享到所有已安装的应用程序。它的工作,同时分享到其他应用程序,如Facebook和电子邮件。

这是我的代码:

bmp = getBitmapFromURL(url);

try {
    File cachePath = new File(getActivity().getCacheDir(), "images");
    cachePath.mkdirs();
    FileOutputStream stream = new FileOutputStream(cachePath + "/image.png");
    bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
    stream.close();
} catch (FileNotFoundException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}

File imagePath = new File(getActivity().getCacheDir(), "images");
File newFile = new File(imagePath, "image.png");
Uri contentUri = FileProvider.getUriForFile(getActivity(), "com.xxxx.xxxxxxxx.fileprovider", newFile);

if (contentUri != null) {
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 
    shareIntent.setDataAndType(contentUri, getActivity().getContentResolver().getType(contentUri));
    shareIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
    startActivity(Intent.createChooser(shareIntent, "Share image via..."));
}

当我将我的图像分享到LINE应用弹出窗口时出现此文本"发生了错误。请稍后重试"

这是来自logcat的错误消息:

03-18 14:49:29.950 2944-3440/? E/PersonaManagerService: inState():  stateMachine is null !!
03-18 14:49:29.955 2944-3440/? E/Parcel: Class not found when unmarshalling: jp.naver.line.android.activity.chathistory.ChatHistoryRequest
03-18 14:49:29.955 2944-3440/? E/Parcel: java.lang.ClassNotFoundException: jp.naver.line.android.activity.chathistory.ChatHistoryRequest
03-18 14:49:29.955 2944-3440/? E/Parcel:     at java.lang.Class.classForName(Native Method)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at java.lang.Class.forName(Class.java:308)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at java.lang.Class.forName(Class.java:272)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.os.Parcel.readParcelableCreator(Parcel.java:2275)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.os.Parcel.readParcelable(Parcel.java:2239)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.os.Parcel.readValue(Parcel.java:2146)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.os.Parcel.readArrayMapInternal(Parcel.java:2479)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.os.BaseBundle.unparcel(BaseBundle.java:221)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.os.BaseBundle.getString(BaseBundle.java:918)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.content.Intent.getStringExtra(Intent.java:5422)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1871)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1413)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:5057)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:4842)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:142)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3247)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.os.Binder.execTransact(Binder.java:446)
03-18 14:49:29.955 2944-3440/? E/Parcel:  Caused by: java.lang.ClassNotFoundException: Didn't find class "jp.naver.line.android.activity.chathistory.ChatHistoryRequest" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
03-18 14:49:29.955 2944-3440/? E/Parcel:     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at java.lang.Class.classForName(Native Method) 
03-18 14:49:29.955 2944-3440/? E/Parcel:     at java.lang.Class.forName(Class.java:308) 
03-18 14:49:29.955 2944-3440/? E/Parcel:     at java.lang.Class.forName(Class.java:272) 
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.os.Parcel.readParcelableCreator(Parcel.java:2275) 
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.os.Parcel.readParcelable(Parcel.java:2239) 
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.os.Parcel.readValue(Parcel.java:2146) 
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.os.Parcel.readArrayMapInternal(Parcel.java:2479) 
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.os.BaseBundle.unparcel(BaseBundle.java:221) 
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.os.BaseBundle.getString(BaseBundle.java:918) 
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.content.Intent.getStringExtra(Intent.java:5422) 
03-18 14:49:29.955 2944-3440/? E/Parcel:     at com.android.server.am.ActivityStackSupervisor.startActivityLocked(ActivityStackSupervisor.java:1871) 
03-18 14:49:29.955 2944-3440/? E/Parcel:     at com.android.server.am.ActivityStackSupervisor.startActivityMayWait(ActivityStackSupervisor.java:1413) 
03-18 14:49:29.955 2944-3440/? E/Parcel:     at com.android.server.am.ActivityManagerService.startActivityAsUser(ActivityManagerService.java:5057) 
03-18 14:49:29.955 2944-3440/? E/Parcel:     at com.android.server.am.ActivityManagerService.startActivity(ActivityManagerService.java:4842) 
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:142) 
03-18 14:49:29.955 2944-3440/? E/Parcel:     at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3247) 
03-18 14:49:29.955 2944-3440/? E/Parcel:     at android.os.Binder.execTransact(Binder.java:446) 
03-18 14:49:29.955 2944-3440/? E/Parcel:    Suppressed: java.lang.ClassNotFoundException: jp.naver.line.android.activity.chathistory.ChatHistoryRequest
03-18 14:49:29.955 2944-3440/? E/Parcel:     at java.lang.Class.classForName(Native Method)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
03-18 14:49:29.955 2944-3440/? E/Parcel:     at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
03-18 14:49:29.955 2944-3440/? E/Parcel:            ... 18 more
03-18 14:49:29.955 2944-3440/? E/Parcel:  Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
03-18 14:49:29.960 2944-3440/? E/WindowState: getStack: Window{2f1a3245 u0 jp.naver.line.android/jp.naver.line.android.activity.main.MainActivity} couldn't find taskId=2391 Callers=com.android.server.wm.WindowState.getDisplayContent:1220 com.android.server.wm.WindowState.isDefaultDisplay:1824 com.android.server.wm.WindowState.getMultiWindowStyleLw:2353 com.android.server.wm.WindowManagerService.setFocusedApp:5601 
03-18 14:49:29.980 15673-15673/? E/ViewRootImpl: sendUserActionEvent() mView == null
03-18 14:49:30.005 2333-27831/? E/AudioPlayer: >>> setAudioEffect Error mAudioFormat : 1, event : 218893323, value : 252710414
03-18 14:49:30.140 27834-27834/? E/SDP.PUB_CRYPTOD: Failed to open the netlink socket with error: Protocol not supported 
03-18 14:49:30.140 27834-27834/? E/SDP.PUB_CRYPTOD: Exiting 

任何人都知道为什么或我使用错误的方式来分享图像

0 个答案:

没有答案