Difference between revisions of "KiwixKolibri"

Jump to navigation Jump to search
More details for android integration between apps
(added sample code that could be useful for Kiwix<-->Kolibri initegration on Android)
(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


From my limited understanding, we can define two custom `scheme`s such that:
We can define two custom `scheme`s such that:
  - ACTION_VIEW intents that start with `kolibri://<path>` will be handled by the Kolibiri app,
* ACTION_VIEW intents that start with `kolibri://<path>` will be handled by the Kolibiri app (see below)
  - and ACTION_VIEW intents starting with `kiwix://<path>` will be handled by the Kiwix app,
* 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 need:
We could something like this in the Kolibri android app manifest:
  <nowiki>
   
    <activity
    <activity
        android:name=".activities.LinkDispatcherActivity"
        android:name=".activities.LinkDispatcherActivity"
        android:noHistory="true"
        android:noHistory="true"
        android:launchMode="singleInstance"
        android:launchMode="singleInstance"
        android:theme="@android:style/Theme.NoDisplay" >
        android:theme="@android:style/Theme.NoDisplay" >
        <intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE"/>
            <category android:name="android.intent.category.BROWSABLE"/>
            <data android:scheme="kolibri"/>
            <data android:scheme="'''kolibri'''"/>
            <data android:host="view_channel"/>
            '''<nowiki><data android:host="view_channel"/></nowiki>
            <data android:host="view_node"/>
            <nowiki><data android:host="view_node"/></nowiki>'''
            <data android:pathPattern=".*"/>
            <nowiki><data android:pathPattern=".*"/></nowiki>
        </intent-filter>
        </intent-filter>
    </activity>
    </activity>
</nowiki>


in the Kiwix android app
in the Kiwix android app
  <nowiki>
   
    <activity
    <activity
        android:name=".activities.LinkDispatcherActivity"
        android:name=".activities.LinkDispatcherActivity"
        android:noHistory="true"
        android:noHistory="true"
        android:launchMode="singleInstance"
        android:launchMode="singleInstance"
        android:theme="@android:style/Theme.NoDisplay" >
        android:theme="@android:style/Theme.NoDisplay" >
        <intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.BROWSABLE"/>
            <category android:name="android.intent.category.BROWSABLE"/>
            <data android:scheme="kiwix"/>
            <data android:scheme="'''kiwix'''"/>
            <data android:host="view_zimfile"/>
            '''<nowiki><data android:host="view_zimfile"/></nowiki>
            <data android:host="view_page"/>
            <nowiki><data android:host="view_page"/></nowiki>'''
            <data android:pathPattern=".*"/>
            <nowiki><data android:pathPattern=".*"/></nowiki>
        </intent-filter>
        </intent-filter>
    </activity>
    </activity>
</nowiki>
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 ==
16

edits

Navigation menu