android统计
‘壹’ android 6.0 的友盟统计实时日志没有
总体来说,友盟里面的东西还是不错的,这段时间,一直在用友盟,感触最深的就是 做分享的时候,有的Android机型是不可以的分享的,直接报错,我用的是友盟的4.3 有一部手机是Android5.0的 当分享sina时 报错 找了各种资料 最后改动了一个文件类,同事帮忙解决了 ( ^_^ ) 有一个华为手机 分享QQ空间 直接手机无响应,这是个别的手机,方正Android机型太多了 太多奇葩了 有的人可能会说用ShareSDK 我感觉不错用哪个第三方 ,遇到问题了都要解决的 我们做这个项目之前用过推送和更新版本,所以直接用了友盟分享,总之 还是不错的。
配置友盟权限和方法
[html] view plain print?
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<!-- Permission for Unit Test -->
<uses-permission android:name="android.permission.GET_TASKS"
‘贰’ 如何在有盟统计中看android机型分布
code/p/achartengine/downloads/list 这是Google做的achartengine,里面有条形图的,但愿有用,你也可以用Canvas自己来画图,也很简单
‘叁’ 有没有安卓手机软件能够统计每天看了手机多少次 有没有软件能统计睡觉时间的
好像还没有软件这么先进,虽然我知道怎么做安卓软件,但是你指的看手机次数,睡觉时间统计,是指开关屏的次数还是手机被眼球望了几次?睡觉时间是你睡觉前看下时间,醒了再看一下时间就知道睡觉睡了多久了。没有你想的那么先进的设备能测出你睡觉睡了多久的。我只能帮你到这儿了。。。。。。
‘肆’ android统计工具有哪些
android统计工具有吆喝科技的ab测试
‘伍’ 如何实现android累计流量统计
1、获取已安装app
java">List<PackageInfo>packageInfos=packageManager.getInstalledPackage(PackageManager.GET_PERMISSIONS);
2、循环对每个app判断是否有申请INTERNET权限,有则继续执行
for(PackageInfopackageInfo:packageInfos){
if(packageInfo.requestedPermissions.contains("android.permission.INTERNET")){
//执行第3步的获取
}
}
3、获取该app的名字以及上传/下载流量统计(先获取该app在整个手机中的专属id:uid,再通过TrafficStats的get方法获取)
4、将获取到的全部数据记录到自定义的javabean,然后集合到list集合中,最后在listview中设置适配器,将数据显示出来。
‘陆’ Android如何统计一个进程的流量消耗呢
2.2之后引入了一个新的 android.net.TrafficStats类可以做到网络流量统计,可以统计总流量也可以统计单个进程的流量。对于Android流量统计来说在2.2版中加入了TrafficStats类可以轻松获取,其实本身TrafficStats类也是读取Linux提供的文件对象系统类型的文本进行解析。android.net.TrafficStats类中,提供了多种静态方法,可以直接调用获取,返回类型均为long型,如果返回等于-1代表 UNSUPPORTED 当前设备不支持统计。static long getMobileRxBytes() //获取通过Mobile连接收到的字节总数,但不包含WiFistatic long getMobileRxPackets() //获取Mobile连接收到的数据包总数static long getMobileTxBytes() //Mobile发送的总字节数static long getMobileTxPackets() //Mobile发送的总数据包数static long getTotalRxBytes() //获取总的接受字节数,包含Mobile和WiFi等static long getTotalRxPackets() //总的接受数据包数,包含Mobile和WiFi等static long getTotalTxBytes() //总的发送字节数,包含Mobile和WiFi等static long getTotalTxPackets() //发送的总数据包数,包含Mobile和WiFi等static long getUidRxBytes(int uid) //获取某个网络UID的接受字节数static long getUidTxBytes(int uid) //获取某个网络UID的发送字节数Android如何统计一个进程的流量消耗呢
‘柒’ android如何监控统计各个应用程序运行的时间
1.打开拨号,输入*#*#4636#*#*
备注:此数据通常关机清零
‘捌’ 安卓APP如何统计流量
安卓app统计流量使用,方式如下:
因为getUidRxBytes(int uid)和getUidTxbytes(int uid)包括了所有网络形式的流量,即包括WIFI和3g/2g.故需要监听WIFI变化,并记录WIFI过程中该uid应用使用的流量记录.
`
stants{
@Override
publicvoidonReceive(Contextcontext,Intentintent){
if(intent.getAction().equals(WifiManager.WIFI_STATE_CHANGED_ACTION)){
intwifistate=intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,WifiManager.WIFI_STATE_DISABLED);
if(wifistate==WifiManager.WIFI_STATE_DISABLED){//如果关闭
//结余本次wifi过程中uid应用的流量
}elseif(wifistate==WifiManager.WIFI_STATE_ENABLED){
//记录当前uid应用的流量.
}
}
}
‘玖’ 关于android应用启动次数统计
UsageStatsService 这个service能得到PkgUsageStats的launchCount,试试看吧
‘拾’ 在Android中要实现图表统计该怎么做
package com.yzxy.draw;
import java.util.ArrayList;
import java.util.HashMap;
import com.yzxy.draw.tools.Tools;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.RectF;
import android.graphics.Paint.Style;
import android.graphics.Typeface;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
@SuppressLint("ViewConstructor")
class MyTuView extends View{
public static final int RECT_SIZE = 10;
private Point mSelectedPoint = null;
public static enum Mstyle
{
Line,scroll
}
private Mstyle mstyle=Mstyle.Line;
private Point[] mPoints = new Point[8];
Context context;
Activity act;
int bheight=0;
Tools tool=new Tools();
HashMap map;
ArrayList dlk;
int totalvalue=30;
int pjvalue=5;
String xstr,ystr;
int margint=15;
int marginb=40;
int c=0;
int resid=0;
Boolean isylineshow;
public MyTuView(Context context,HashMap map,int totalvalue,int pjvalue,String xstr,String ystr,Boolean isylineshow)
{
super(context);
this.context=context;
this.act = (Activity)context;
this.map=map;
this.totalvalue=totalvalue;
this.pjvalue=pjvalue;
this.xstr=xstr;
this.ystr=ystr;
this.isylineshow=isylineshow;
act.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// canvas.drawColor(Color.GRAY);
if(c!=0)
this.setbg(c);
if(resid!=0)
this.setBackgroundResource(resid);
dlk=tool.getintfrommap(map);
int height=getHeight();
if(bheight==0)
bheight=height-marginb;
int width=getWidth();
Log.i("w", getWidth()+":"+getHeight());
int blwidh=tool.dip2px(context,50);
int pjsize=totalvalue/pjvalue;
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.GRAY);
paint.setStrokeWidth(1);
paint.setStyle(Style.STROKE);
// 画直线(横向)
for(int i=0;i xlist=new ArrayList();//记录每个x的值
//画直线(纵向)
for(int i=0;i dlk,HashMap map,ArrayList xlist,int max,int h)
{
Point[] points=new Point[dlk.size()];
for(int i=0;i getMap() {
return map;
}
public void setMap(HashMap map) {
this.map = map;
}
public int getTotalvalue() {
return totalvalue;
}
public void setTotalvalue(int totalvalue) {
this.totalvalue = totalvalue;
}
public int getPjvalue() {
return pjvalue;
}
public void setPjvalue(int pjvalue) {
this.pjvalue = pjvalue;
}
public String getXstr() {
return xstr;
}
public void setXstr(String xstr) {
this.xstr = xstr;
}
public String getYstr() {
return ystr;
}
public void setYstr(String ystr) {
this.ystr = ystr;
}
public int getMargint() {
return margint;
}
public void setMargint(int margint) {
this.margint = margint;
}
public Boolean getIsylineshow() {
return isylineshow;
}
public void setIsylineshow(Boolean isylineshow) {
this.isylineshow = isylineshow;
}
public int getMarginb() {
return marginb;
}
public void setMarginb(int marginb) {
this.marginb = marginb;
}
public Mstyle getMstyle() {
return mstyle;
}
public void setMstyle(Mstyle mstyle) {
this.mstyle = mstyle;
}
public int getBheight() {
return bheight;
}
public void setBheight(int bheight) {
this.bheight = bheight;
}
public int getC() {
return c;
}
public void setC(int c) {
this.c = c;
}
public int getResid() {
return resid;
}
public void setResid(int resid) {
this.resid = resid;
}
}
代码片段
package com.yzxy.draw.tools;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Environment;
public class Tools
{
private final static String ALBUM_PATH = Environment.getExternalStorageDirectory() + "/yueqiu/";
public int dip2px(Context context, float dpValue)
{
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}
public int px2dip(Context context, float pxValue)
{
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}
public ArrayList getintfrommap(HashMap map)
{
ArrayList dlk=new ArrayList();
int position=0;
@SuppressWarnings("rawtypes")
Set set= map.entrySet();
@SuppressWarnings("rawtypes")
Iterator iterator = set.iterator();
while(iterator.hasNext())
{
@SuppressWarnings("rawtypes")
Map.Entry mapentry = (Map.Entry)iterator.next();
dlk.add((Double)mapentry.getKey());
}
for(int i=0;i
代码片段
package com.yzxy.draw;
import java.io.IOException;
import java.util.HashMap;
import com.yzxy.draw.MyTuView.Mstyle;
import com.yzxy.draw.tools.Tools;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.Toast;
import android.app.Activity;
import android.content.res.XmlResourceParser;
import android.graphics.Bitmap;
import android.graphics.Color;
public class MainActivity extends Activity {
MyTuView tu;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
HashMap map=new HashMap();
map.put(1.0, 8.0);
map.put(7.0, 130.0);
map.put(2.0, 4.0);
map.put(3.0, 1.0);
map.put(4.0, 18.0);
map.put(5.0, 160.0);
map.put(6.0, 180.0);
map.put(8.1, 133.5);
tu=new MyTuView(this,map,200,50,"x","y",false);
// tu.setC(Color.CYAN);
tu.setResid(R.drawable.bg);
// tu.setBheight(200);
tu.setTotalvalue(200);
tu.setPjvalue(50);
tu.setXstr("x");
tu.setYstr("y");
tu.setMargint(20);
tu.setBackgroundColor(Color.WHITE);
tu.setMarginb(50);
tu.setMstyle(Mstyle.scroll);
RelativeLayout rela=getlayout(R.layout.activity_main);
rela.addView(tu);
LayoutParams parm=new LayoutParams(1200,400);
parm.setMargins(50, 50, 50, 100);
tu.setLayoutParams(parm);
setContentView(rela);
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
// TODO Auto-generated method stub
if(item.getItemId() == R.id.menu_settings)
{
if (false == tu.isDrawingCacheEnabled())
{
tu.setDrawingCacheEnabled(true);
}
Bitmap bitmap = tu.getDrawingCache();
Tools tool=new Tools();
try {
Boolean b=tool.saveFile(bitmap, "aaaa.png");
if(b)
Toast.makeText(this, "success", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(item.getItemId() == R.id.menu_ch)
{
HashMap map=new HashMap();
map.put(1.0, 21.0);
map.put(3.0, 25.0);
map.put(4.0, 32.0);
map.put(5.0, 31.0);
map.put(6.0, 26.0);
tu.setTotalvalue(40);
tu.setPjvalue(10);
tu.setMap(map);
tu.setIsylineshow(true);
tu.postInvalidate();
}
if(item.getItemId() == R.id.menu_ch2)
{
HashMap map=new HashMap();
map.put(1.0, 41.0);
map.put(3.0, 25.0);
map.put(4.0, 32.0);
map.put(5.0, 41.0);
map.put(6.0, 16.0);
map.put(7.0, 36.0);
map.put(8.0, 26.0);
tu.setTotalvalue(50);
tu.setPjvalue(10);
tu.setMap(map);
tu.setMstyle(Mstyle.Line);
tu.setIsylineshow(false);
tu.postInvalidate();
}
return true;
}
public RelativeLayout getlayout(int r)
{
LayoutInflater inflater = (LayoutInflater)getSystemService(android.content.Context.LAYOUT_INFLATER_SERVICE );
try {
XmlResourceParser parser = getResources().getLayout(r);
RelativeLayout layout = (RelativeLayout) inflater.inflate(parser, null);
return layout;
}catch (Exception e) {
// TODO: handle exception
}
return null;
}
}