16
edits
Ivan.Savov (talk | contribs) (added sample code that could be useful for Kiwix<-->Kolibri initegration on Android) |
Ivan.Savov (talk | contribs) (More details for android integration between apps) |
||
Line 77: | Line 77: | ||
# [https://tech.just-eat.com/2015/06/29/deep-linking-in-android-the-easy-way/ Article about ACTION_VIEWs] using a custom scheme | # [https://tech.just-eat.com/2015/06/29/deep-linking-in-android-the-easy-way/ Article about ACTION_VIEWs] using a custom scheme | ||
We can define two custom `scheme`s such that: | |||
* ACTION_VIEW intents that start with `kolibri://<path>` will be handled by the Kolibiri app (see below) | |||
* ACTION_VIEW intents starting with `kiwix://<path>` will be handled by the Kiwix app, | |||
* Suppose you're in the Kiwix app and you're browsing some videos from KA zim file. The exercises don't work within the Kiwix appthough, but you can click on an perseus exercise and the Kiwix app will send you to the Kolibri app as follows Uri exercise = Uri.parse("kolibri:/learn/#/1ceff53605.../topics/c/845ce535...");<br> Intent callIntent = new Intent(Intent.ACTION_VIEW, exercise); // do check here callIntent.startActivity() | |||
We could something like this in the Kolibri android app manifest | We could something like this in the Kolibri android app manifest: | ||
<activity | |||
android:name=".activities.LinkDispatcherActivity" | |||
android:noHistory="true" | |||
android:launchMode="singleInstance" | |||
android:theme="@android:style/Theme.NoDisplay" > | |||
<intent-filter> | |||
<action android:name="android.intent.action.VIEW"/> | |||
<category android:name="android.intent.category.DEFAULT"/> | |||
<category android:name="android.intent.category.BROWSABLE"/> | |||
<data android:scheme="'''kolibri'''"/> | |||
'''<nowiki><data android:host="view_channel"/></nowiki> | |||
<nowiki><data android:host="view_node"/></nowiki>''' | |||
<nowiki><data android:pathPattern=".*"/></nowiki> | |||
</intent-filter> | |||
</activity> | |||
in the Kiwix android app | in the Kiwix android app | ||
<activity | |||
android:name=".activities.LinkDispatcherActivity" | |||
android:noHistory="true" | |||
android:launchMode="singleInstance" | |||
android:theme="@android:style/Theme.NoDisplay" > | |||
<intent-filter> | |||
<action android:name="android.intent.action.VIEW"/> | |||
<category android:name="android.intent.category.DEFAULT"/> | |||
<category android:name="android.intent.category.BROWSABLE"/> | |||
<data android:scheme="'''kiwix'''"/> | |||
'''<nowiki><data android:host="view_zimfile"/></nowiki> | |||
<nowiki><data android:host="view_page"/></nowiki>''' | |||
<nowiki><data android:pathPattern=".*"/></nowiki> | |||
</intent-filter> | |||
</activity> | |||
</ | To verify there is an activity available that can respond to the intent, call <code>queryIntentActivities()</code> to get a list of activities capable of handling your <code>Intent</code>. If the returned <code>List</code> is not empty, you can safely use the intent. For example: | ||
PackageManager packageManager = <code>getPackageManager()</code>;<br> | |||
List = activities = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); | |||
boolean isIntentSafe = activities.size() > 0; | |||
If <code>isIntentSafe</code> is <code>true</code>, then we know that the intent-receiving app is installed and will respond to the intent. | |||
== Stickers & Swag == | == Stickers & Swag == |
edits