动态获取android锁屏包名

Aka*_*mar 5 android lockscreen package-name

我需要获取android锁屏活动的包名.我用google搜索除了/sf/answers/1181674511/之外什么都没找到,这似乎不起作用.

有没有办法获得锁屏包名称

Mav*_*eňツ 0

获取所有进程的列表,然后检查屏幕锁定应用程序包名称。

下面是代码:

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));
}
Run Code Online (Sandbox Code Playgroud)

日志猫:

TAG: Process com.android.systemui has been running since: 86526 ms 
Run Code Online (Sandbox Code Playgroud)

那是锁屏^

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 
Run Code Online (Sandbox Code Playgroud)