Android14开机动画延时3秒

From 168846b2a9353f4f64e6b45fdbcbc4a09f25dd35 Mon Sep 17 00:00:00 2001
From: lsh <lsh@example.com>
Date: Thu, 9 Jan 2025 19:20:59 +0800
Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E6=9C=BA=E5=8A=A8=E7=94=BB=E6=92=AD?=
 =?UTF-8?q?=E6=94=BE=E5=89=8D=E5=BB=B6=E6=97=B63=E7=A7=92,=20=E4=BF=AE?=
 =?UTF-8?q?=E5=A4=8D=E4=BB=8E=E7=AC=AC1=E5=B8=A7=E5=BC=80=E5=A7=8B?=
 =?UTF-8?q?=E6=92=AD=E6=94=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 device/rockchip/rk3576/rk3576_u/rk3576_u.mk          | 10 +++++++++-
 frameworks/base/cmds/bootanimation/BootAnimation.cpp |  7 +++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/device/rockchip/rk3576/rk3576_u/rk3576_u.mk b/device/rockchip/rk3576/rk3576_u/rk3576_u.mk
index 7c7ffb33b94..b214bccd1ad 100755
--- a/device/rockchip/rk3576/rk3576_u/rk3576_u.mk
+++ b/device/rockchip/rk3576/rk3576_u/rk3576_u.mk
@@ -48,4 +48,12 @@ PRODUCT_PROPERTY_OVERRIDES += persist.wifi.sleep.delay.ms=0
 PRODUCT_PROPERTY_OVERRIDES += persist.bt.power.down=true
 PRODUCT_PROPERTY_OVERRIDES += vendor.hwc.device.primary=DSI
 PRODUCT_PROPERTY_OVERRIDES += vendor.hwc.device.extend=HDMI-A,eDP
-PRODUCT_SYSTEM_EXT_PROPERTIES += ro.lockscreen.disable.default=true
\ No newline at end of file
+PRODUCT_SYSTEM_EXT_PROPERTIES += ro.lockscreen.disable.default=true
+#
+## add CZM properties
+#
+#########################################
+# delaytime for playing bootanimation
+# ms
+PRODUCT_PROPERTY_OVERRIDES += \
+	persist.sys.bootani.delaytime=3000
diff --git a/frameworks/base/cmds/bootanimation/BootAnimation.cpp b/frameworks/base/cmds/bootanimation/BootAnimation.cpp
index 0400fdc5daa..e8afbca9064 100755
--- a/frameworks/base/cmds/bootanimation/BootAnimation.cpp
+++ b/frameworks/base/cmds/bootanimation/BootAnimation.cpp
@@ -1402,6 +1402,9 @@ bool BootAnimation::preloadZip(Animation& animation) {
 }
 
 bool BootAnimation::movie() {
+    const float CHECK_DELAY = 1*1000;
+    char value[PROPERTY_VALUE_MAX];
+
     if (mAnimation == nullptr) {
         mAnimation = loadAnimation(mZipFileName);
     }
@@ -1475,6 +1478,10 @@ bool BootAnimation::movie() {
         initDynamicColors();
     }
 
+    //add delaytime set ,default 0.
+    property_get("persist.sys.bootani.delaytime", value, "0");
+    int delay_new = atoi(value);//ms
+    usleep(CHECK_DELAY * delay_new);
     playAnimation(*mAnimation);
 
     if (mTimeCheckThread != nullptr) {
-- 
2.17.1


### 如何在 Android Studio 中自定义应用启动动画 #### 创建 Lottie 动画资源文件 为了实现更复杂的启动动画效果,在 `assets` 文件夹下放置 JSON 格式的 Lottie 动画文件是一个常见做法。如果项目中尚未存在此文件夹,则可以在 app/src/main/ 下创建它。 ```json // assets/lottie_animation.json { "v": "5.7.3", ... } ``` #### 修改布局文件以支持 Lottie 动画显示 编辑 `activity_splash_screen.xml` 布局文件来引入 LottieAnimationView 组件用于播放动画[^2]: ```xml <!-- res/layout/activity_splash_screen.xml --> <com.airbnb.lottie.LottieAnimationView xmlns:lottie="http://schemas.android.com/apk/res-auto" android:id="@+id/animation_view" android:layout_width="wrap_content" android:layout_height="wrap_content" lottie_fileName="lottie_animation.json"/> ``` #### 编辑 Java 或 Kotlin 类设置启动逻辑 通过重载 Activity 的 `onCreate()` 方法并调用相应 API 来加载和播放动画,同时配置延迟跳转至主界面的时间间隔: ```java protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash_screen); final Intent intent = new Intent(this, MainActivity.class); LottieAnimationView animationView = findViewById(R.id.animation_view); animationView.setAnimation("lottie_animation.json"); animationView.playAnimation(); Handler handler = new Handler(); handler.postDelayed(() -> startActivity(intent), 3000); // 设置延时时间为三 } ``` 对于使用Kotlin的情况: ```kotlin override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_splash_screen) val intent = Intent(this@SplashScreenActivity, MainActivity::class.java) val animationView : LottieAnimationView = findViewById(R.id.animation_view) animationView.setAnimation("lottie_animation.json") animationView.playAnimation() Handler().postDelayed({ startActivity(intent) }, 3000) // 设置延时时间为三 } ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值