导航:首页 > 操作系统 > android统计库

android统计库

发布时间:2024-08-21 16:51:55

⑴ 在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;
}
}

⑵ Android的APP,是怎么做渠道统计的

安卓渠道统计方案

方法1:通常传统的做法是对不同渠道进行分包发布,每个渠道打一个标识唯一的渠道id的安装包,再收集渠道安装数据。这种方式有些弊端,如果渠道很多的话比如说有100个渠道要推广,就得手工打100个渠道包,这样做的话技术人员就比较辛苦了。另一个弊端就是应用市场会存在抓包的情况,这样就会造成数据不准的情况。

方法2:用渠道链接替代渠道安装包做渠道统计,这种方案就可以免去手工打渠道包,而且统计数据会更精确。具体实现请参考openinstall的官网 www.openinstall.io

⑶ android 统计sdk怎么做

导入Analytics_Android_SDK_3.0.jar(简称SDK)
下载最新版sdk的zip包,解压将其中的Analytics_Android_SDK_3.0.jar释放到本地目录,Eclipse用户右键您的工程根目录,选择Properties -> Java Build Path -> Libraries, 然后点击Add External JARs... 选择指向 Analytics_Android_SDK_3.0.jar 的路径,点击OK,即导入成功。

配置AndroidManifest.xml
android.permission.INTERNET 向我们的服务器发送用户分析数据。
android.permission.READ_PHONE_STATE 这个权限仅为了获取用户手机的IMEI,用来唯一的标识用户。(如果您的应用会运行在无法读取IMEI的平板上,我们会将mac地址作为用户的唯一标识,请添加权限: android.permission.ACCESS_WIFI_STATE )

⑷ Android应用统计-使用时长及次数统计(一)

最近在做有关于应用统计有关的工作,主要是统计系统中客户端应用(非系统自带的那些基础应用,比如DownLoadManager),在每一天的使用情况,统计内容包括:应用打开次数,应用合计使用时长等。
在所搜寻的方案中,大致有如下两种:

以下方案采用两个方案并行,主要是以系统数据统计结果为主,以自行记录的数据作为参照,用以对比两组数据,以保证数据统计结果的有效性和稳定性。

在Android中,系统会自行记录应用的打开次数和使用时间,且提供了相关api于开发者,但是每一次版本提升都可能会对api带来相当大的改变,这一块也不例外。但是始终没有变化的就是在拨号键盘输入* # * #4636# * #*,进入工程模式,点击“使用情况统计数据”,你就可以看到统计界面了。由于各个版本之间差异比较大,而且相关的资料也比较少,本次使用的api以及相关的说明都是以Android-5.1为基础。在某些版本中,应用统计api,存在不少缺陷以及避坑的地方,尤其是手机厂家修改过源码之后,所以对于某些品牌的测试机器,程序的运行结果会有一点不一样,请各位读者有所注意。

本文主要介绍了关于Android系统中统计各个app的使用情况的解决方案,以及获取相关数据的方法。关于系统记录的数据的原理以及在该原理的逻辑下可能出现的bug,将会在接下来的文章中详细阐述。

github: UseTimeStatistic
参考文献:
Android 5.0以上通过UsageStatsManager类 获取应用使用情况(精品)
android如何获取系统里各个应用的使用时间?
Android UsageStatsService:要点解析
Android5.1应用打开次数获取

下一篇:Android应用统计-使用时长及次数统计(二)

⑸ 手机android 编程怎么画出折线统计图

后来发现一个更加强大的开源框架MPAndroidChart。

下面简单介绍下MPAndroidChart,MPAndroidChart的效果还是蛮好的,提供各种动画,这个也是我使用MPAndroidChart,而且放弃achartengine的原因。

Github地址连接,后面是youtube上面演示MPAndroidChart的视频,MPAndroidChart由于提供了动画效果,为了兼容低版本的Android系统,MPAndroidChart需要添加nineoldandroids-2.4.0-2.jar作为依赖库,所以如果项目中使用这个表格库,需要同时导入这个两个jar,当然如果使用libproject的方式,就不用了。

核心功能:

支持x,y轴缩放

支持拖拽

支持手指滑动

支持高亮显示

支持保存图表到文件中

支持从文件(txt)中读取数据

预先定义颜色模板

自动生成标注

支持自定义x,y轴的显示标签

支持x,y轴动画

支持x,y轴设置最大值和附加信息

支持自定义字体,颜色,背景,手势,虚线等

显示的图表类型:

LineChart (with legend, simple design) (线性图)

⑹ 如何统计Android手机各个应用的使用时间以及使用次数

一:通过反射com.android.internal.os.PkgUsageStats来获取你想要的信息

二:应用的启动大部分应该都是在桌面上点击从而启动的,所以可以在桌面launcher中做统计处理,也可以把统计数据共享给某个应用。
望采纳

阅读全文

与android统计库相关的资料

热点内容
网页无法打开pdf 浏览:555
linux命令scp 浏览:519
怎样把图片转为pdf格式 浏览:115
linux变量类型 浏览:840
linux中网卡配置 浏览:704
appstore里面的软件怎么设定年龄 浏览:290
jpg在线转换pdf格式 浏览:600
java泛型详解 浏览:616
pdf介质框 浏览:210
苹果手机怎么用蓝牙传app软件到安卓 浏览:435
东方财富app怎么找场内基金 浏览:276
粉笔app怎么修改身份 浏览:529
价值投资选股公式源码 浏览:681
u盘文件夹变成了白色隐藏无法使用 浏览:876
python如何爬取火车票 浏览:977
生命哲学pdf 浏览:61
socket程序源码 浏览:156
修改文件夹用户和用户组 浏览:595
女生隐私软件不加密不要钱 浏览:560
压缩式雾化泵和雾化器一样吗 浏览:675