I need to get package name of android lock screen activity. I have googled found nothing except https://mcmap.net/q/1917860/-how-do-i-get-android-lockscreen-package-name which doesn't seem to work.
Is there any way to get lock screen package name
I need to get package name of android lock screen activity. I have googled found nothing except https://mcmap.net/q/1917860/-how-do-i-get-android-lockscreen-package-name which doesn't seem to work.
Is there any way to get lock screen package name
You can determine the package name for any Activity
that comes to the foreground by analyzing the Android logs. For example, if you have Google Maps open, clicking on the device's Home button will show this in the log (I usually filter by the ActivityManager
string).
START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME]
flg=0x10200000 cmp=com.android.launcher/com.android.launcher2.Launcher}
Which shows you that the package name of the home screen Activity
is com.android.launcher
However, when I click my Nexus 4 home button to show the lockscreen from any app, it never shows another Activity being launched. This makes me think that it's not what we understand as a typical Activity
.
If you look at the source for KeyguardViewMediator.java the Android source code, you will find a method named private void doKeyguardLocked(Bundle options)
. I know from experience that changing the source to return immediately from this method will disable the lockscreen. The source for KeyguardViewMediator.java
shows that it is in the package com.android.keyguard
, and I believe that this is the package that you are looking for.
As for getting the package name dynamically, it doesn't seem possible to me. But, if you already know the package name ahead of time, then there's no need to get it dynamically.
I hope this helps.
Getting list of all the processes and then check for screen lock app package name.
Below is the Code:
ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
List<ActivityManager.RunningServiceInfo> services = activityManager.getRunningServices(Integer.MAX_VALUE);
long currentMillis = Calendar.getInstance().getTimeInMillis();
Calendar cal = Calendar.getInstance();
for (ActivityManager.RunningServiceInfo info : services) {
cal.setTimeInMillis(currentMillis-info.activeSince);
Log.i("TAG", String.format("Process %s has been running since: %d ms",info.process, info.activeSince));
}
Logcat:
TAG: Process com.android.systemui has been running since: 86526 ms
That is the lock screen ^
TAG: Process com.qualcomm.telephony has been running since: 68521 ms
TAG: Process com.motorola.ccc has been running since: 57456 ms
TAG: Process com.google.android.music:main has been running since: 26245 ms
TAG: Process com.android.phone has been running since: 29421 ms
TAG: Process com.motorola.ccc has been running since: 52141 ms
TAG: Process system has been running since: 28602 ms
TAG: Process com.motorola.actions has been running since: 74371 ms
TAG: Process com.motorola.ccc has been running since: 59166 ms
TAG: Process com.motorola.process.slpc has been running since: 25483 ms
TAG: Process com.android.systemui has been running since: 30142 ms
TAG: Process com.android.bluetooth has been running since: 22187 ms
TAG: Process system has been running since: 28603 ms
TAG: Process com.google.android.gms.persistent has been running since: 31621 ms
TAG: Process com.android.systemui has been running since: 27361 ms
TAG: Process com.google.android.gms.persistent has been running since: 99678 ms
TAG: Process com.motorola.contacts.preloadcontacts has been running since: 45603 ms
TAG: Process com.google.android.gms.persistent has been running since: 73457 ms
TAG: Process com.google.android.gms.persistent has been running since: 72908 ms
TAG: Process com.google.android.gms.persistent has been running since: 37251
© 2022 - 2024 — McMap. All rights reserved.