Trying to get lunch count using mAppLaunchCount from UsageStats

32 views Asked by At

I am trying to get mAppLaunchCount from UsageStats but not able to do that

 UsageStatsManager usageStatsManager = (UsageStatsManager) var10000;
            Log.d("TAG", "" + usageStatsManager);

 List<UsageStats> queryUsageStats = usageStatsManager.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, currentTime - (long) 600000, currentTime);
            Log.d("TAG", "" + queryUsageStats);

enter image description here

As you can we I even got mAppLaunchCount but I am not able to get that field. So I searched about it and got this .

Field mAppLaunchCount = null;
                    try {
                        mAppLaunchCount = UsageStats.class.getField("mAppLaunchCount");
                        Log.d("tag",""+mAppLaunchCount);
                        int launchCount = (Integer) mAppLaunchCount.get(queryUsageStats.get(i));
                        Log.d("tag",""+launchCount);
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    }

but even using this i not able to get mAppLaunchCount. can any one help me ...

0

There are 0 answers