I am working on an android application where I am using instant app feature too. I have a navigation drawer where I have few navigation view items, in main feature module.
- TV
- Movies
- Search
When a user clicks on TV item then it will open fragment which has tab layout.
- Trending
- Popular
- Watched
I have to design application keep in mind that it should support instant app functionality too. If a user is requesting for TV then it should only download TV module kinda.
I have created an app, base, instant-app, main modules. I created launcher activity in the main module and setup NavigationDrawer
of the application. I am thinking to create another module for the TV which will have tablayout a) Trending b) Popular c) Watched (Fragments)
AndroidManifest.xml(Main Module)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.main">
<application>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter android:order="1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:host="example.com" />
<data android:pathPattern="/main" />
<data android:scheme="https" />
<data android:scheme="http" />
</intent-filter>
</activity>
</application>
</manifest>
I am keeping common things like styles, drawable, layouts and services and few activities in the base module as according to instant app concept.
As TV module contains only tab layout so it will only have fragment - Trending, Popular, Watched.
Does anyone know how I can set different URL for tv feature module so it can access with the different address like https://www.example.com/tv? If I do all these stuff in the main module then instant app feature concept will fail.
I am a newbie in instant app, don't know much if I am using correct approach too here. I appreciate if anyone can help me who have experience with it.
Each feature apk needs to have an activity as an entry point that is URL addressable. With this in mind, there will need to be a
TvActivity
that is included in the tv feature module. This activity can contain the tab layout that loads the different TV centric fragments.The
AndroidManifest.xml
file in the tv feature module will look something like:When clicking on TV from the
NavigationDrawer
it should fire anIntent
to launch the URLhttps://example.com/tv
and this will download the feature apk (if required) and start theTvActivity
.