2016-11-15 35 views
0

我正在使用下面的代码将图像分享到想要的应用程序,除了viber以外,这些应用程序对大多数应用程序都适用。每当我想分享图像Viber的,Viber的用folliwng错误崩溃:如何通过文件提供程序将图像共享到viber应用程序?

FATAL EXCEPTION: ThreadManager::idleTasksHandler 
           Process: com.viber.voip, PID: 16668 
           java.lang.IllegalArgumentException: column '_data' does not exist 
            at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:303) 
            at android.database.CursorWrapper.getColumnIndexOrThrow(CursorWrapper.java:78) 
            at com.viber.voip.util.aw.a(SourceFile:238) 
            at com.viber.voip.util.aw.b(SourceFile:206) 
            at com.viber.voip.util.aw.a(SourceFile:141) 
            at com.viber.voip.util.b.n.a(SourceFile:1204) 
            at com.viber.voip.util.bm.run(SourceFile:207) 
            at android.os.Handler.handleCallback(Handler.java:739) 
            at android.os.Handler.dispatchMessage(Handler.java:95) 
            at com.viber.voip.be.dispatchMessage(SourceFile:32) 
            at android.os.Looper.loop(Looper.java:135) 
            at android.os.HandlerThread.run(HandlerThread.java:61) 
            at com.viber.voip.cj.run(SourceFile:100) 

我Uriess看起来像content://com.myapp.fileprovider/share_images/nxt_emoji_26.png
代码

​​

回答

1

Viber的提交人是没有经验的,并认为所有contentUri值来自MediaStore,因此他们正在查询不存在的_data列。

My LegacyCompatCursorWrapper可以与FileProvider一起使用,尝试根据this Stack Overflow answer中显示的方法改进与Viber等错误应用的兼容性。 This sample app演示了LegacyCompatCursorWrapper的使用。你继承FileProvider,覆盖query(),并包裹由super.query()返回CursorLegacyCompatCursorWrapper

/*** 
Copyright (c) 2015 CommonsWare, LLC 
Licensed under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance with the License. You may obtain a copy 
of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required 
by applicable law or agreed to in writing, software distributed under the 
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
OF ANY KIND, either express or implied. See the License for the specific 
language governing permissions and limitations under the License. 

From _The Busy Coder's Guide to Android Development_ 
https://commonsware.com/Android 
*/ 

package com.commonsware.android.cp.v4file; 

import android.database.Cursor; 
import android.net.Uri; 
import android.support.v4.content.FileProvider; 
import com.commonsware.cwac.provider.LegacyCompatCursorWrapper; 

public class LegacyCompatFileProvider extends FileProvider { 
    @Override 
    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { 
    return(new LegacyCompatCursorWrapper(super.query(uri, projection, selection, selectionArgs, sortOrder))); 
    } 
} 

然后,在清单注册您的FileProvider子类,否则,就像您FileProvider使用它。

+0

我已经尝试这个PDF解决方案,它不会工作。您是否通过viber为PDF共享提供了一些解决方案,PDF文件存储在我的内存中。 – eJoe

相关问题