We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
安卓开发过程中,遇到了一些有点冷而又相对重要的知识点。特地去开篇显得少了。汇总下一起发布总结下。
Android Studio 会自动为您创建“debug”build 类型和“release”build 类型 如果要改变build类型,在菜单栏中依次选择 Build > Select Build Variant。 吐槽下要一个个改,不能批量改,真是蠢。
与代码交互 app模块会自动生成BuildConfig类
public final class BuildConfig { public static final boolean DEBUG = false; public static final String APPLICATION_ID = "com.xxx.xxxx"; public static final String BUILD_TYPE = "release"; public static final int VERSION_CODE = 83; public static final String VERSION_NAME = "8.3"; }
参考 配置 build 类型 更改构建变体
直接上代码。API30全屏处理有新的api
protected void hideBottomUIMenu() { if( !BuildConfig.DEBUG ) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) { View decorView = getWindow().getDecorView(); int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN; decorView.setSystemUiVisibility(uiOptions); } else { getWindow().getInsetsController().setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE); getWindow().getInsetsController().hide(WindowInsets.Type.navigationBars() | WindowInsets.Type.statusBars()); } } }
参考 WindowInsetsController
应用场景是这样的。我在其中一个module里面声明了一个receiver。但是在app实际组装过程中,并不是所有的app都要。有的想要注册这个receiver,有的不想要,怎么办。 官挡的推荐是从app模块的build.gradle里面注入。我们直接上代码
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.space365.basic"> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <application android:allowBackup="false"> <receiver android:name=".BootReceiver" android:enabled="${boot}" android:exported="true"> <intent-filter android:priority="1000"> <action android:name="android.intent.action.BOOT_COMPLETED" /> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </receiver> </application> </manifest>
这里${boot}作为占位变量
defaultConfig { applicationId "com.space365.app.gate.shgbit" minSdkVersion rootProject.minSdkVersion targetSdkVersion rootProject.targetSdkVersion versionCode 1 versionName "1.0" manifestPlaceholders = [boot:true] testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" }
这里使用manifestPlaceholders变量定义变量数组
The text was updated successfully, but these errors were encountered:
No branches or pull requests
前言
安卓开发过程中,遇到了一些有点冷而又相对重要的知识点。特地去开篇显得少了。汇总下一起发布总结下。
1.Build Variant
Android Studio 会自动为您创建“debug”build 类型和“release”build 类型
如果要改变build类型,在菜单栏中依次选择 Build > Select Build Variant。
吐槽下要一个个改,不能批量改,真是蠢。
与代码交互
app模块会自动生成BuildConfig类
参考
配置 build 类型
更改构建变体
2. 应用全屏显示
直接上代码。API30全屏处理有新的api
参考
WindowInsetsController
3.AndroidManifest.xml动态配置变量
应用场景是这样的。我在其中一个module里面声明了一个receiver。但是在app实际组装过程中,并不是所有的app都要。有的想要注册这个receiver,有的不想要,怎么办。
官挡的推荐是从app模块的build.gradle里面注入。我们直接上代码
这里${boot}作为占位变量
这里使用manifestPlaceholders变量定义变量数组
将构建变量注入清单
The text was updated successfully, but these errors were encountered: