usage-statistics

Count and limit the number of users on my app

风流意气都作罢 提交于 2019-11-27 07:20:52
问题 I need to implement a system to limit the number of users that can concurrently use my app. I am thinking the best way to go is to count the number of sessions currently active and then limit based on that. How can I count the number of sessions currently active. I am using memcached to store my sessions if that makes a difference 回答1: I think the easiest way is to intercept the session's open , destroy and gc callbacks (using session_set_save_handler()) and increment/decrement a session

Android Usage Access for Android 5 Samsung devices

≯℡__Kan透↙ 提交于 2019-11-27 02:05:48
问题 As you might know, since Android 5 was launched, accessing the recent tasks (usage stats) of your device requires the user to enable this feature manually (Settings->Security->Usage Access). My app checks if the device uses Android 5, and if so, then it offers the user the possibility of opening the settings screen for enabling usage access: Intent intent = new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS); startActivityForResult(intent, 12345); The problem comes when I try to do this in a

How to check if “android.permission.PACKAGE_USAGE_STATS” permission is given?

对着背影说爱祢 提交于 2019-11-26 20:23:58
Background I'm trying to get app-launched statistics, and on Lollipop it's possible by using the UsageStatsManager class, as such (original post here ): manifest: <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" tools:ignore="ProtectedPermissions"/> opening the activity that will let the user confirm giving you this permission: startActivity(new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS)); getting the stats, aggregated : private static final String USAGE_STATS_SERVICE ="usagestats"; // Context.USAGE_STATS_SERVICE); ... final UsageStatsManager usageStatsManager=

TrafficStats Api android and calculation of daily data usage

…衆ロ難τιáo~ 提交于 2019-11-26 17:46:30
问题 Have a confusion over following two methods of TrafficStats of Android: getUidTxBytes(int uid) and getUidRxBytes(int uid) , These two methods return the number of bytes transmitted and received through the network for this UID. But what is the time unit of it, is it per second? If I want to calculate data transmitted and received per day per app, what should I do. I thought one way, to store data in sql and keep on adding data to the table. Is it proper way? 回答1: These are counters "since the

How to Track App Usage in Android? How to detect when an activity is launched?

假如想象 提交于 2019-11-26 15:38:36
问题 I need to track app usage in Android like how AppUsage does it (i.e. track number of app launches, and time spent using each). What I plan on doing is record the start time when an app is launched, and then get the end time when an app is paused or stopped. In LogCat, I'm able to see logs of Activity starting. I've looked at the available system broadcasts, I'm not sure if there is anything that broadcasts whenever an activity is started. . Basically, how do I detect when an activity is

How to use UsageStatsManager?

微笑、不失礼 提交于 2019-11-26 11:10:36
Background Google has deprecated the function " getRecentTasks " of "ActivityManager" class. Now all it does is to get the list of apps that the current app has opened. I've even written a post about it here on StackOverflow , but I noticed it's impossible. The problem I've made a post about it ( here , and another, similar one created by someone else, here ) and requested to re-consider it, and Google decided to make a new class, that seem to provide a similar functionality (more like statistics, but might also be useful), but I can't find out how to use it. The class is called "

How can I find the data usage on a per-application basis on Android?

只谈情不闲聊 提交于 2019-11-26 10:19:51
I am trying to find out the data usage on Android on a per-application basis. Something like Android Data Usage Apps and Quota / Cap Monitor Widgets: never get charged extra for data or get capped again! . I looked at Stack Overflow question How to go about detecting data usage in the Android environment . But it's not been of much help. ActivityManager activityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE); ActivityManager.MemoryInfo mInfo = new ActivityManager.MemoryInfo(); activityManager.getMemoryInfo( mInfo ); List<RunningAppProcessInfo> listOfRunningProcess =

How to create a Service which continuously monitors app usage information?

怎甘沉沦 提交于 2019-11-26 10:09:37
问题 Problem at Hand : I have to create a Service which runs continuously. This service monitors 5 apps say 5 android games installed on your phone. This service needs to get the information of: 1. How many times is the game opened and run? 2. For how much time each game has run. for example: Say If I have this service installed in my app. And I let it run for a month. I need information of this kind on the screen of the app: Game Number of times the game is run Duration of Game play Game 1 20