我正在开发一个 Android 应用程序,我也在其中使用即时应用程序功能。在主要功能模块中,我有一个抽屉导航,其中几乎没有导航 View 项。
- 电视
- 电影
- 搜索
当用户点击电视项目时,它将打开具有标签布局的 fragment 。
- 热门
- 受欢迎
- 看过
我必须在设计应用程序时牢记它也应该支持即时应用程序功能。如果用户请求电视,那么它应该只下载电视模块。
我已经创建了一个应用程序、基础、即时应用程序、主要模块。我在主模块中创建了启动器 Activity 并设置了应用程序的 NavigationDrawer
。我正在考虑为电视创建另一个模块,它将有 tablayout a) 趋势 b) 流行 c) 观看( fragment )
AndroidManifest.xml(主模块)
<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>
根据免安装应用程序的概念,我在基础模块中保留了样式、可绘制对象、布局和服务等常见内容以及一些 Activity 。
由于电视模块仅包含选项卡布局,因此它只会包含 fragment - 热门、热门、已观看。
有谁知道如何为电视功能模块设置不同的 URL,以便它可以使用不同的地址访问,例如 https://www.example.com/tv ?如果我在主模块中做所有这些事情,那么即时应用程序功能概念将失败。
我是即时应用程序的新手,不知道我在这里是否也使用了正确的方法。如果有经验的人可以帮助我,我将不胜感激。
最佳答案
每个功能 apk 都需要有一个 Activity 作为入口点,该入口点是可通过 URL 寻址的。考虑到这一点,tv 功能模块 中将需要包含一个 TvActivity
。此 Activity 可以包含加载不同电视中心 fragment 的选项卡布局。
电视功能模块中的 AndroidManifest.xml
文件将如下所示:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.main.tv">
<application>
<activity android:name=".TvActivity">
<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:path="/tv" />
<data android:scheme="https" />
<data android:scheme="http" />
</intent-filter>
</activity>
</application>
当从 NavigationDrawer
点击 TV 时,它应该触发一个 Intent
来启动 URL https://example.com/tv
这将下载功能 apk(如果需要)并启动 TvActivity
。
关于Android 即时应用程序设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45999458/