android - NetworkStatsManager's queries take too long -


i'm trying statistics of traffic used on last 30days on each application using networkstatsmanager , wrote code following :

thread thread = new thread(new runnable() { @override public void run() {  networkstatsmanager networkstatsmanager = (networkstatsmanager) getactivity().getsystemservice(context.network_stats_service);     networkstats networkstats = null;     log.d("ccc","start----"+system.currenttimemillis());     networkstats = networkstatsmanager.querysummary(connectivitymanager.type_wifi,"",                                 system.currenttimemillis()-2592000000l,                                 system.currenttimemillis());     log.d("ccc","end-"+system.currenttimemillis());     } catch (remoteexception e) {}      networkstats.bucket bucket = new networkstats.bucket();     while (networkstats!=null && networkstats.hasnextbucket()) {     networkstats.getnextbucket(bucket);       log.d("ccc",bucket.getuid()+"---"+bucket.gettxbytes()+"---"+bucket.getrxbytes()); } }); thread.start(); 

returned result seems correct the problem is, query takes time respond -usually 25 seconds- , if want both type_wifi , type_mobile internet usage over 50 seconds, not good. there approach this? or perhaps doing wrong here causes delay? thank in advance.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -