maybe my question sounds like asked 100 times before, but believe me I have read every answer for those 100 similar questions and non of them solved my problem. So purpose of my native extension is to share documents in my app cache folder (doc, pdf, etc.) with third party apps (Quick Office, Adobe Reader etc). I found that FileProvider and Intents should solve my problem.
My app description file contains:
<application android:enabled="true"
android:launchMode="singleInstance">
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.test.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
In Eclipse in Project properties -> Java Build Path -> Order and Export selected: Android Private libraries and Android Dependencies. android-support-v4.jar is inside project's libs folder.
FREFunction code excerpt:
package com.test.OpenWithDefaultApp.functions;
.....
import android.content.Intent;
import android.net.Uri;
import android.support.v4.content.FileProvider;
.....
Uri contentUri = FileProvider.getUriForFile(context.getActivity(), "com.test.OpemWithDefaultApp.fileprovider", file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(contentUri, fileType);
.....
context.getActivity().startActivity(intent);
.....
I'm using
Eclipse Luna 4.4.0
Eclipse Android Plugin 23.0.3
Android SDK Tools 23.0.2
Android SDK Platform-tools 20
Android SDK Build-tools 20
Android SDK from 14 upto 20
Android Support Library 20
Google Play services 19
Native extension structure:
+android
-libs/android-support-v4.jar
-res/xml/file_paths
-library.swf
-openwithdefaultapp.jar
+default
-library.swf
-extension.xml
But I'm stuck with error:
java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" on path: DexPathList[[zip file "/data/app/air.testFileProvider-2.apk"],nativeLibraryDirectories=[/data/app-lib/air.testFileProvider-2, /vendor/lib, /system/lib]]
Any help would be appreciated. Thanks
android:authorities="com.test.fileprovider"
and "com.test.OpemWithDefaultApp.fileprovider"
, both these names should be same