Android How to get the number of times an application has been executed/opened for all installed apps
I was trying to see how many times an app has been opened/used so far.
Using this I can get a list of ResolveInfos, which contain all packageManagerInfo I might need. But I don't know if there is any field or method that would return me the number of times that this application has been executed/opened.
Or maybe there's a much simpler way I just don't know.
public List<ResolveInfo> getInstalledApps(Context context) {
final Intent mainInte开发者_Go百科nt = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
return context.getPackageManager().queryIntentActivities(mainIntent, 0);
}
Many thanks in advance, Sakura
Use a shared preference (http://developer.android.com/guide/topics/data/data-storage.html#pref) as a counter.
精彩评论