gpt4 book ai didi

android - 检测用户何时在 Android 设备上启动新应用程序

转载 作者:搜寻专家 更新时间:2023-11-01 09:07:24 26 4
gpt4 key购买 nike

我一直在尝试检测用户何时在他/她的设备上启动应用程序。

所以我找到了这个解决方案:

https://stackoverflow.com/a/7239840/833219

我在一个线程中添加了这段代码。所以我的应用程序每 3 毫秒获取一次日志,但我找不到日志之间的区别,所以我无法检测到用户应用程序启动的代码。

这是我添加此行时得到的日志示例:

String w = log.toString();
Log.i("LockService","w ="+w);



06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc android.process.media for broadcast com.android.providers.media/.UsbReceiver: pid=375 uid=10013 gids={1015, 1023, 1024, 2001, 3003, 3007}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc com.google.android.inputmethod.latin.dictionarypack for content provider com.google.android.inputmethod.latin.dictionarypack/.DictionaryProvider: pid=407 uid=10043 gids={3003, 1015}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc android.process.acore for content provider com.android.providers.userdictionary/.UserDictionaryProvider: pid=421 uid=10002 gids={3003, 1015}
06-04 00:20:14.765: I/LockService(854): W/ActivityManager( 142): Unable to start service Intent { act=com.android.internal.telephony.IWapPushManager }: not found
06-04 00:20:14.765: I/LockService(854): W/ActivityManager( 142): Unable to start service Intent { act=com.android.ussd.IExtendedNetworkService }: not found
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc com.android.settings for broadcast com.android.settings/.widget.SettingsAppWidgetProvider: pid=476 uid=1000 gids={1015, 3002, 3001, 3003, 3007}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc com.android.contacts for broadcast com.android.contacts/.calllog.CallLogReceiver: pid=505 uid=10002 gids={3003, 1015}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc com.android.providers.calendar for broadcast com.android.providers.calendar/.CalendarReceiver: pid=545 uid=10007 gids={3003, 1015}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Config changed: {1.0 605mcc1mnc fr_FR layoutdir=0 sw320dp w320dp h508dp nrml long port finger -keyb/v/h -nav/h s.4}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc com.google.android.deskclock for broadcast com.google.android.deskclock/com.android.deskclock.AlarmInitReceiver: pid=562 uid=10012 gids={}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc com.google.android.email for broadcast com.google.android.email/com.android.email.service.EmailBroadcastReceiver: pid=577 uid=10014 gids={3003, 1015}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc com.google.android.exchange for service com.google.android.exchange/com.android.exchange.ExchangeService: pid=596 uid=10025 gids={3003, 1015}
06-04 00:20:14.765: I/LockService(854): I/ActivityManager( 142): Start proc com.google.android.apps.genie.geniewidget for broadcast com.google.android.apps.genie.geniewidge
06-04 00:20:15.082: I/LockService(854): w =--------- beginning of /dev/log/system
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Memory class: 48
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Config changed: {1.0 0mcc0mnc fr_FR layoutdir=0 sw320dp w320dp h508dp nrml long port ?uimode ?night finger -keyb/v/h -nav/h s.2}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): System now ready
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Start proc com.android.systemui for service com.android.systemui/.SystemUIService: pid=210 uid=1000 gids={1015, 3002, 3001, 3003, 3007}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Start proc com.google.android.gsf.login for service com.google.android.gsf.login/com.google.android.gsf.loginservice.GoogleLoginService: pid=238 uid=10018 gids={3003, 1015, 1007, 2001, 3006}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Start proc com.google.process.gapps for content provider com.google.android.gsf/.gservices.GservicesProvider: pid=262 uid=10018 gids={3003, 1015, 1007, 2001, 3006}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Config changed: {1.0 0mcc0mnc fr_FR layoutdir=0 sw320dp w320dp h508dp nrml long port finger -keyb/v/h -nav/h s.3}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Start proc com.android.wallpaper for service com.android.wallpaper/.nexus.NexusWallpaper: pid=289 uid=10027 gids={1006}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Start proc com.google.android.inputmethod.latin for service com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME: pid=301 uid=10024 gids={}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Start proc com.android.phone for added application com.android.phone: pid=316 uid=1001 gids={3002, 3001, 3003, 1015}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Start proc com.android.nfc for added application com.android.nfc: pid=331 uid=1027 gids={3002, 3001}
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): START {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000000 cmp=com.android.launcher/com.android.launcher2.Launcher} from pid 0
06-04 00:20:15.082: I/LockService(854): I/ActivityManager( 142): Start proc com.android.launcher for activity com.android.launcher/com.android.launcher2.Launcher: pid=354 uid=10026 gids={}

使用此代码,我如何检测用户是否启动了应用程序?

最佳答案

阅读日志是一个糟糕的想法,而且在系统版本之间也存在问题。实际上有一个您可以注册的广播 Intent here : ACTION_PACKAGE_FIRST_LAUNCH,但是请注意,这仅适用于 API 级别 12+。

关于android - 检测用户何时在 Android 设备上启动新应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10874904/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com