简体   繁体   English

如何从服务 Android Q 启动活动

[英]How to Start Activity From Service Android Q

Hi Developers I hope All are You fine.嗨开发人员我希望你一切都好。 I need help.我需要帮助。 I make a AppLocker app and I use service to check which app i currently running.我制作了一个 AppLocker 应用程序,并使用服务来检查我当前正在运行的应用程序。 i locked app in my database with package name.我使用 package 名称将应用程序锁定在我的数据库中。 When I show my lock screen From Service my Intent hit but lockScreen not Showing.How i call Activity From Service below is my Codeto start Activty from Service当我从服务显示我的锁定屏幕时,我的 Intent 命中但 lockScreen 未显示。我如何从服务调用 Activity 下面是我从服务启动 Activty 的代码

if (locker_list!=null) {
                            if (launchapp) {
                                Log.d("TAG", "run: lock Screen Show");
                                Intent intent = new Intent(mContext, Lock_app_screen.class);
                                intent.putExtra("package_name", current_app);
                                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                                mContext.startActivity(intent);
                        }
                    }

Android 10 (API level 29) and higher place restrictions on when apps can start activities when the app is running in the background. Android 10(API 级别 29)和更高的地方限制了当应用程序在后台运行时应用程序何时可以启动活动。 These restrictions help minimize interruptions for the user and keep the user more in control of what's shown on their screen.这些限制有助于最大限度地减少对用户的干扰,并使用户更好地控制屏幕上显示的内容。 for more... see this更多... 看到这个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM