chan00010 发表于 2024-12-27 09:48 public void onHomePressed() { if (getSharedPreferences("general_file", 0).getBoolean("home_buzaitixing", true)) { Intent intent = new Intent(this, (Class<?>) IndexActivity.class); intent.addFlags(268435456); PendingIntent.getActivity(this, 0, intent, 0).send(); } } 代码优化一下 |
本帖最后由 gvs123 于 2024-12-29 10:45 编辑 行者1823 发表于 2024-12-27 10:36 麻烦大佬看一下这个教程,是不是还是修改当被桌面 给桌面权限。如果可以的话 麻烦大佬修改下乐视专版。就这个真的不会黑屏。 ![]() |
public void onHomePressed() { String myPkgName = getPackageName(); SharedPreferences sp = getSharedPreferences("general_file", 0); if (res == null) { if (getHomes() != null && !getHomes().equals(myPkgName) && sp.getBoolean("home_buzaitixing", true)) { Intent intent = new Intent(this, (Class<?>) IndexActivity.class); intent.addFlags(268435456); PendingIntent.getActivity(this, 0, intent, 0).send(); return; } return; } if (!res.activityInfo.packageName.equals(myPkgName) && sp.getBoolean("home_buzaitixing", true)) { Intent intent2 = new Intent(this, (Class<?>) IndexActivity.class); intent2.addFlags(268435456); PendingIntent.getActivity(this, 0, intent2, 0).send(); } } |
Android 点击Home键之后启动Activity会延迟5秒的情况 就是当通过 home 键将当前 activity 置于后台时,任何在后台startActivity 的操作都将会延迟 5 秒,除非该应用获取了 “android.permission.STOP_APP_SWITCHES” 权限。 关于延迟 5 秒的操作在 com.android.server.am.ActivityManagerService 中的 stopAppSwitches() 方法中,系统级的应用当获取了 “android.permission.STOP_APP_SWITCHES” 后将不会调用到这个方法来延迟通过后台启动 activity 的操作,事实上 android 原生的 Phone 应用就是这样的情况,它是一个获取了”android.permission.STOP_APP_SWITCHES” 权限的系统级应用,当有来电时,一个从后台启动的 activity 将突然出现在用户的面前,警醒用户有新的来电,这样的设计是合理的。 关于此问题的解决方案 1. 获取以下权限 android.permission.STOP_APP_SWITCHES` 2. 通过以下方式启动activity Intent intent = new Intent(context, TransparentActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0); pendingIntent.send(); |
cdc10 发表于 2024-12-26 22:30 能提供一下固件吗,我找的固件按home键无反应 |
chan00010 发表于 2025-3-4 11:07 请教一下 这个具体改哪里啊 |
chan00010 发表于 2025-3-4 11:07 你好这个代码放哪里面啊 告知一下 |
行者1823 发表于 2024-12-27 10:36 ![]() |
AndroidManifest.xml是哪个apk里的? |
home.JPG (106.8 KB, 下载次数: 9)
本帖最后由 orchid_zxg 于 2024-12-28 11:05 编辑 chan00010 发表于 2024-12-27 09:44 具体怎么操作?修改哪个文件?在网上查到,在AndroidManifest.xml里添加: <uses-permission android:name="android.permission.STOP_APP_SWITCHES" /> 在Android.mk里添加: LOCAL_CERTIFICATE := platform 打开Android.mk文件,看到类似字段: ############################## include $(CLEAR_VARS) LOCAL_MODULE := ajvm LOCAL_SRC_FILES := ajvm.apk LOCAL_MODULE_CLASS := APPS LOCAL_MODULE_SUFFIX := .apk LOCAL_BUILT_MODULE_STEM := package.apk LOCAL_MODULE_TARGET_ARCH := arm LOCAL_CERTIFICATE := platform include $(BUILD_PREBUILT) ############################## |
这功能确实有些多余,按下主页键,系统跳出一个桌面选择对话框,当欠桌面也跳出一个桌面选择对话框。 |
Archiver|新帖|标签|软件|Sitemap|ZNDS智能电视网 ( 苏ICP备2023012627号 )
网络信息服务信用承诺书 | 增值电信业务经营许可证:苏B2-20221768 丨 苏公网安备 32011402011373号
GMT+8, 2025-8-4 15:00 , Processed in 0.054482 second(s), 14 queries , Redis On.