开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜