在声明可信任的Web活动(android.support.customtabs.trusted.STATUS_BAR_COLOR)时,您应该在AndroidManifest中添加新的元数据。
<activity android:name="android.support.customtabs.trusted.LauncherActivity">
<meta-data
android:name="android.support.customtabs.trusted.DEFAULT_URL"
android:value="https://your-host.com/" />
<meta-data
android:name="android.support.customtabs.trusted.STATUS_BAR_COLOR"
android:resource="@color/colorPrimaryDark" />
<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="https"
android:host="your-host.com"/>
</intent-filter>
</activity>
protected CustomTabsIntent getCustomTabsIntent(CustomTabsSession session) {
return new CustomTabsIntent.Builder(session)
.setToolbarColor(Color.parseColor("#FF0000"))
.build();
}
#FF0000
替换为所需颜色即可。app/src/main/LauncherActivity.java
吗?而且我找不到任何路径在AndroidManifest.xml
中,我如何更改对副本的引用? - Budiactivity
标签中,您需要更改:android:name=com.example.LauncherActivity
。 - andrebancom.devMonkeys.expenser
重构为com.expenser
是正常的吗?另外,请编辑您的帖子并解释人们需要在LauncherActivity.java
的第15行中更改package
名称 :) 在您发布的函数中,我遇到了错误:cannot resolve symbol Color
,其他东西看起来都很好。 - Budierror: cannnot find symbol variable TrustedWebActivityService
。 - Budiimport android.support.customtabs.trusted.TrustedWebActivityService;
现在它运行得很好 :) 非常感谢andreban为您的大力帮助和支持!我相信这个主题会帮助很多人 :) 您是否有关于Launcher Activity自定义选项的文档链接? - Budipublic void setStatusBarColor(int color) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(color);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}