我尝试使用此意图从本地存储共享PNG图像:
Intent intent = new Intent(Intent.ACTION_SEND, imageUri)
.putExtra(Intent.EXTRA_STREAM, imageUri)
.putExtra(Intent.EXTRA_TEXT, text)
.putExtra("com.pinterest.EXTRA_DESCRIPTION", "123")
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
.setType("image/png");
return Intent.createChooser(intent, "Share with");
它为Facebook,Instagram等工作。但是对于Pinterest而言,只有在Android 6.0.1上我才能得到这个奇怪的例外:
Caused by: java.lang.IllegalStateException: Couldn't read row 0, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
at android.database.CursorWindow.nativeGetLong(Native Method)
at android.database.CursorWindow.getLong(CursorWindow.java:511)
at android.database.CursorWindow.getInt(CursorWindow.java:578)
at android.database.AbstractWindowedCursor.getInt(AbstractWindowedCursor.java:69)
at android.database.CursorWrapper.getInt(CursorWrapper.java:122)
at com.pinterest.common.kit.utils.ImageUtils.getRotationForImage(SourceFile:231)
at com.pinterest.common.kit.utils.ImageUtils.rotateBitmapIfNeeded(SourceFile:201)
at com.pinterest.common.kit.utils.ImageUtils.imageFromUri(SourceFile:145)
at com.pinterest.activity.create.fragment.CreateBaseFragment.setImageUri(SourceFile:604)
at com.pinterest.activity.create.fragment.CreateBaseFragment.init(SourceFile:330)
at com.pinterest.activity.create.fragment.CreateBaseFragment.onCreateView(SourceFile:120)
at android.support.v4.app.Fragment.performCreateView(SourceFile:1974)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1067)
at android.support.v4.app.FragmentManagerImpl.moveToState(SourceFile:1252)
at android.support.v4.app.BackStackRecord.run(SourceFile:738)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(SourceFile:1617)
at android.support.v4.app.FragmentController.execPendingActions(SourceFile:339)
at android.support.v4.app.FragmentActivity.onStart(SourceFile:602)
at com.pinterest.kit.activity.SocialConnectActivity.onStart(SourceFile:111)
at com.pinterest.kit.activity.BaseActivity.onStart(SourceFile:90)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1237)
at android.app.Activity.performStart(Activity.java:6268)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
你能帮忙解决吗? Pinterest SDK不是一个选项。
答案 0 :(得分:1)
使用LegacyCompatFileProvider
在CommonsWare的帮助下解决。
答案 1 :(得分:0)
我通过将图像插入媒体商店然后将该URI用于Pinterest来实现它。
String urlOfShareImage = MediaStore.Images.Media.insertImage(getContentResolver(), outputFile.getPath(), outputFile.getName(), "Share text");
Uri shareImageUri = Uri.parse(urlOfShareImage);
// Pass this URI to the share intent.