Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UsageStatsManager usage = (UsageStatsManager) getSystemService(Context.USAGE_STATS_SERVICE);
- long time = System.currentTimeMillis();
- Calendar currentDate = Calendar.getInstance();
- currentDate.set(currentDate.get(Calendar.YEAR),currentDate.get(Calendar.MONTH),currentDate.get(Calendar.DATE),0,0,0);
- List<UsageStats> stats = usage.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, currentDate.getTimeInMillis(), time);
- if (stats != null)
- {
- SortedMap<Long, UsageStats> runningTask = new TreeMap<Long,UsageStats>();
- for (UsageStats usageStats : stats) {
- runningTask.put(usageStats.getLastTimeUsed(), usageStats);
- Log.e("USAGESTATUS", "===== CheckPhoneState isRooting packageName = " + usageStats.getPackageName());
- Log.e("USAGESTATUS", "===== CheckPhoneState Time = " + usageStats.getTotalTimeInForeground());
- // stats.getPackgeName();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement