【问题标题】:Share to Pinterest doesn't work on Marshmallow分享到 Pinterest 不适用于棉花糖
【发布时间】:2016-07-08 23:35:25
【问题描述】:

我正在尝试使用此意图从本地存储共享 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 不是一个选项。

【问题讨论】:

标签: android share android-6.0-marshmallow pinterest


【解决方案1】:

CommonsWare 的帮助下使用LegacyCompatFileProvider 解决了。

【讨论】:

    【解决方案2】:

    我通过将图像插入媒体商店然后使用 Pinterest 的 URI 来使其工作。

    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.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-01-18
      • 2016-08-27
      • 2016-03-15
      • 2019-11-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多