1.0.0 • Published 8 years ago
cordova-file-association v1.0.0
cordova-fileAssociation
File association plugin for cordova. Main purpose is to make possible to associate cordova app with file types well known or custom made. Currently it is for Android only.
How to use it 1.Clone from git git clone 2.Configure your AndroidManifest.xml activity for example for json file:
....
<!--
opening by email application
-->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/json" />
</intent-filter>
<!--
opening from remote ex. with http (ex. browser)
-->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:host="*" />
<data android:pathPattern=".*\\.json" />
</intent-filter>
.....
</activity>
window.plugins.fileAssociation.getAssociatedData(null,
function (success) {
try {
if (success != null) {
//handle your data here maybe ex. by promise
activityPromise.resolve(decoded);
}
} catch (e) {
activityPromise.reject(e);
}
}, function (error) {
activityPromise.reject(error);
});
};
//added to be sure that plgin is available document.addEventListener("resume", function () { loadFromActivity(); }, false);
document.addEventListener("deviceready", function () {
loadFromActivity();
}, false);
5.Use well
1.0.0
8 years ago