基于Android的手机计步器的设计与实现源代码
- 格式:docx
- 大小:41.38 KB
- 文档页数:33
基于Android开发的智能健身跟踪器设计与实现智能健身跟踪器是一种结合了传感技术、数据分析和移动应用的智能设备,可以帮助用户记录运动数据、分析运动状态、制定健身计划等。
随着人们对健康生活的重视和智能设备的普及,智能健身跟踪器在市场上受到越来越多的关注和需求。
本文将介绍基于Android开发的智能健身跟踪器的设计与实现过程。
1. 智能健身跟踪器的功能需求分析在设计智能健身跟踪器之前,首先需要明确其功能需求。
一般而言,智能健身跟踪器应该具备以下功能:记录运动数据:包括步数、距离、卡路里消耗等。
分析运动状态:根据用户的运动数据,分析用户的运动状态,如跑步速度、心率等。
制定健身计划:根据用户的运动数据和目标,制定个性化的健身计划。
提供实时反馈:在运动过程中提供实时反馈,引导用户正确进行运动。
数据同步:将用户的运动数据同步到云端,方便用户随时查看和管理。
2. 技术选型与架构设计基于Android开发智能健身跟踪器,需要选择合适的技术和架构。
一般可以采用MVVM(Model-View-ViewModel)架构,使用Kotlin语言进行开发。
同时,可以利用Android Jetpack组件库提供的LiveData、ViewModel等组件来简化开发流程。
在技术选型方面,可以利用Android传感器API获取设备的加速度、陀螺仪等传感数据;使用Room数据库存储用户的运动数据;通过Retrofit库实现与后端服务器的数据交互;借助Google Fit API获取用户的健康数据等。
3. 功能模块设计与实现3.1 用户登录模块用户登录模块是智能健身跟踪器的入口,用户可以通过输入账号密码或第三方登录方式登录应用。
在登录成功后,可以同步用户的个人信息和历史运动数据。
3.2 运动数据记录模块运动数据记录模块负责记录用户的运动数据,包括步数、距离、卡路里消耗等。
可以通过Android传感器获取用户的步数和运动轨迹,并将数据存储到本地数据库中。
<LinearLayout xmlns:android="/apk/res/android"xmlns:tools="/tools"android:id="@+id/LayoutMain"android:layout_width="fill_parent"android:layout_height="fill_parent"android:orientation="vertical"><EditTextandroid:id="@+id/inputString"android:layout_width="fill_parent"android:layout_height="60dp"android:layout_weight="1"android:ems="10"android:inputType="none" ><requestFocus /></EditText><LinearLayoutandroid:id="@+id/LayoutButtons1"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_weight="1"android:orientation="horizontal" ><Buttonandroid:id="@+id/clear"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/clear" /><Buttonandroid:id="@+id/delete"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/delete" /><Buttonandroid:id="@+id/divided"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/divided" /><Buttonandroid:id="@+id/multi"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/multi" /></LinearLayout><LinearLayoutandroid:id="@+id/LayoutButtons2"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_weight="1"android:orientation="horizontal" ><Buttonandroid:id="@+id/seven"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/seven" /><Buttonandroid:id="@+id/eight"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/eight" /><Buttonandroid:id="@+id/nine"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/nine" /><Buttonandroid:id="@+id/minus"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/minus" /></LinearLayout><LinearLayoutandroid:id="@+id/LayoutButtons3"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_weight="1"android:orientation="horizontal" ><Buttonandroid:id="@+id/four"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/four" /><Buttonandroid:id="@+id/five"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/five" /><Buttonandroid:id="@+id/six"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/six" /><Buttonandroid:id="@+id/plus"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/plus" /></LinearLayout><LinearLayoutandroid:id="@+id/LayoutButtons4"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_weight="2"android:orientation="horizontal" ><LinearLayoutandroid:id="@+id/LayoutButtons41"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="3"android:orientation="vertical" ><LinearLayoutandroid:id="@+id/LayoutButtons411"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_weight="1"android:orientation="horizontal" ><Buttonandroid:id="@+id/one"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/one" /><Buttonandroid:id="@+id/two"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/two" /><Buttonandroid:id="@+id/three"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/three" /></LinearLayout><LinearLayoutandroid:id="@+id/LayoutButtons412"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_weight="1"android:orientation="horizontal" ><Buttonandroid:id="@+id/doublezero"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/double_zero" /><Buttonandroid:id="@+id/zero"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/zero" /><Buttonandroid:id="@+id/point"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:text="@string/point" /></LinearLayout></LinearLayout><LinearLayoutandroid:id="@+id/LayoutButtons42"android:layout_width="wrap_content"android:layout_height="fill_parent"android:layout_weight="1"android:orientation="horizontal" ><Buttonandroid:id="@+id/equal"android:layout_width="fill_parent"android:layout_height="fill_parent"android:text="@string/equal" /></LinearLayout></LinearLayout></LinearLayout>package com.nullpointer.calculator.buttons;import java.math.BigDecimal;import java.util.ArrayList;import java.util.Arrays;import java.util.List;import mon.constants.AppConstants; import mon.utils.StringUtils;/***** @author Null Pointer**/public class FunctionButton extends CalculatorButton {/***** @param originalText** @param buttonValue** @return*/@Overridepublic String getResult(String originalText, String buttonValue) { if (AppConstants.CLEAR_STRING.equals(buttonValue)) {return AppConstants.EMPTY_STRING;} else if (AppConstants.DELETE_STRING.equals(buttonValue)) { if (StringUtils.isNotEmpty(originalText)) {return originalText.substring(0, originalText.length() - 1);} else {return AppConstants.EMPTY_STRING;}} else if (AppConstants.EQUAL_STRING.equals(buttonValue)) { return eval(originalText);} else {return AppConstants.EMPTY_STRING;}}/***** @param expression** @return*/private String eval(String expression) {List<String> items = new ArrayList<String>(Arrays.asList(expression .split("\\+|\\-|×|÷")));char[] operators = expression.replaceAll("[^\\+\\-×÷]",AppConstants.EMPTY_STRING).toCharArray();if (items.size() != operators.length + 1) {return AppConstants.ERROR_MESSAGE;}double result = 0d;for (int i = operators.length - 1; i >= 0; i--) {switch (operators[i]) {case AppConstants.OPERATOR_MULTI:result = this.multi(Double.valueOf(items.get(i)),Double.valueOf(items.get(i + 1)));items.remove(i + 1);items.set(i, String.valueOf(result));break;case AppConstants.OPERATOR_DIVIDED:result = this.divided(Double.valueOf(items.get(i)),Double.valueOf(items.get(i + 1)));items.remove(i + 1);items.set(i, String.valueOf(result));break;default:break;}}if (items.size() == 1) {return items.get(0);}operators = expression.replaceAll("[^\\+\\-]",AppConstants.EMPTY_STRING).toCharArray(); for (int i = operators.length - 1; i >= 0; i--) {switch (operators[i]) {case AppConstants.OPERATOR_PLUS:result = this.plus(Double.valueOf(items.get(i)),Double.valueOf(items.get(i + 1)));items.remove(i + 1);items.set(i, String.valueOf(result));break;case AppConstants.OPERATOR_MINUS:result = this.minus(Double.valueOf(items.get(i)),Double.valueOf(items.get(i + 1)));items.remove(i + 1);items.set(i, String.valueOf(result));break;default:break;}}if (items.size() == 1) {return items.get(0);} else {return AppConstants.ERROR_MESSAGE;}}private double plus(double v1, double v2) {BigDecimal b1 = new BigDecimal(Double.toString(v1));BigDecimal b2 = new BigDecimal(Double.toString(v2));return b1.add(b2).doubleValue();}private double minus(double v1, double v2) {BigDecimal b1 = new BigDecimal(Double.toString(v1));BigDecimal b2 = new BigDecimal(Double.toString(v2));return b1.subtract(b2).doubleValue();}private double multi(double v1, double v2) {BigDecimal b1 = new BigDecimal(Double.toString(v1));BigDecimal b2 = new BigDecimal(Double.toString(v2));return b1.multiply(b2).doubleValue();}private double divided(double v1, double v2) {BigDecimal b1 = new BigDecimal(Double.toString(v1));BigDecimal b2 = new BigDecimal(Double.toString(v2));return b1.divide(b2, 10, BigDecimal.ROUND_HALF_UP).doubleValue();}}需要完整的源代码私信我或者发我邮箱*****************明情况(注:下载才发!)。
基于Android的人体运动计步器系统的设计与实现[权威资料]基于Android的人体运动计步器系统的设计与实现摘要:随着Android智能手机的进一步普及,针对Android智能手机内嵌的加速度传感器进行研究,利用人体行走过程中加速度传感器采集数据信息的变化规律,实现对行人脚步探测与计步系统。
该系统内容包括两部分:行人运动数据采集与预处理模块设计和行人脚步识别探测模块设计,能够有效的实现运动数据采集、预处理、步态探测和计步的功能。
关键词:Android;加速度传感器;步态探测TP393 A 1009-3044(2016)15-0094-04Abstract: With the further popularization of Android smartphones,aimed at the acceleration sensor embedded in the Android smartphone conduct a study , based on the changing law of the data information collected by the acceleration sensor during the walking process of human body to realize the pedestrian detection and measurement system. The system consist of two parts: data acquisition andpretreatment module design and pedestrian detection module design,it can effectively achieve the movement of data acquisition, pre-processing, gaitdetection and step counter function.Key words: Android; acceleration sensor;gait detection随着科技的发展,多功能智能设备的应用越来越受到人们的关注,智能手机作为人们工作生活中的必需品,不断地为人们带来快捷和方便。
从零开始学android实现计算器功能⽰例分享(计算器源码)下⾯是效果展⽰:复制代码代码如下:<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" ><LinearLayout android:layout_width="fill_parent"android:layout_height="wrap_content"><TextViewandroid:id="@+id/tvResult"android:layout_width="fill_parent"android:layout_height="wrap_content"android:height="50dp"android:text="@string/tvResult"/></LinearLayout><LinearLayout android:layout_width="fill_parent"android:layout_height="wrap_content"><Buttonandroid:id="@+id/btnBackspace"android:layout_width="wrap_content"android:layout_height="wrap_content"android:width="150dp"android:layout_marginLeft="10dp"android:text="@string/btnbackspace"/><Buttonandroid:id="@+id/btnCE"android:layout_width="wrap_content"android:layout_height="wrap_content"android:width="150dp"android:text="@string/btnCE"/></LinearLayout><LinearLayout android:layout_width="fill_parent"android:layout_height="wrap_content"><Buttonandroid:id="@+id/btn7"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:width="75dp"android:text="@string/btn7"/><Buttonandroid:id="@+id/btn8"android:layout_width="wrap_content"android:layout_height="wrap_content"android:width="75dp"android:text="@string/btn8"/><Buttonandroid:id="@+id/btnDiv"android:layout_width="wrap_content"android:layout_height="wrap_content"android:width="75dp"android:text="@string/btnDiv"/></LinearLayout><LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content"><Buttonandroid:id="@+id/btn4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:width="75dp"android:text="@string/btn4"/><Buttonandroid:id="@+id/btn5"android:layout_width="wrap_content"android:layout_height="wrap_content"android:width="75dp"android:text="@string/btn5"/><Buttonandroid:id="@+id/btn6"android:layout_width="wrap_content"android:layout_height="wrap_content"android:width="75dp"android:text="@string/btn6"/><Buttonandroid:id="@+id/btnMul"android:layout_width="wrap_content"android:layout_height="wrap_content"android:width="75dp"android:text="@string/btnMul"/></LinearLayout><LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content"><Buttonandroid:id="@+id/btn1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:width="75dp"android:text="@string/btn1"/><Buttonandroid:id="@+id/btn2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:width="75dp"android:text="@string/btn2"/><Buttonandroid:id="@+id/btn3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:width="75dp"android:text="@string/btn3"/></LinearLayout><LinearLayout android:layout_width="fill_parent"android:layout_height="wrap_content"><Buttonandroid:id="@+id/btn0"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginLeft="10dp"android:width="75dp"android:text="@string/btn0"/><Buttonandroid:id="@+id/btnC"android:layout_width="wrap_content"android:layout_height="wrap_content"android:width="75dp"android:text="@string/btnC"/><Buttonandroid:id="@+id/btnEqu"android:layout_width="wrap_content"android:layout_height="wrap_content"android:width="75dp"android:text="@string/btnEqu"/><Buttonandroid:id="@+id/btnSub"android:layout_width="wrap_content"android:layout_height="wrap_content"android:width="75dp"android:text="@string/btnSub"/></LinearLayout></LinearLayout>复制代码代码如下:package com.example.week2;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.TextView;import android.app.Activity;public class MainActivity extends Activity implements OnClickListener{ //声明⼀些控件Button btn0=null;Button btn1=null;Button btn2=null;Button btn3=null;Button btn4=null;Button btn5=null;Button btn6=null;Button btn7=null;Button btn8=null;Button btn9=null;Button btnBackspace=null;Button btnCE=null;Button btnMul=null;Button btnDiv=null;Button btnEqu=null;TextView tvResult=null;//声明两个参数。
专业工程综合实训设计报告目录第一章绪论...............................................................课题的背景及意义......................................................系统框架.............................................................. 第二章系统分析...........................................................系统可行性分析.......................................................功能可行性分析...................................................运行环境可行性分析...............................................开发环境简介.........................................................Java Development kit(JDK)介绍..................................Android SDK 介绍.................................................Eclipse开发工具介绍.............................................Android Development Tools(ADT)介绍............................. 第三章 Android开发常用到的技术及环境搭建.................................Android开发常用到的技术.............................................Activity.........................................................Service..........................................................Content Provider 内容提供者......................................Intent 信使......................................................环境搭建..............................................................安装JDK..........................................................安装Eclipse......................................................Android SDK安装................................................ADT安装........................................................ 第四章手机计步器的设计与实现.............................................计步器功能的设计......................................................计步器功能的实现......................................................计步开始及暂停...................................................复位键...........................................................设置步长..........................................................设置体重..........................................................历史记录的查看及删除.............................................. 第五章计步器的界面效果...................................................用户界面..............................................................设置界面..............................................................历史界面..............................................................日历选择界面..........................................................用户离开界面.......................................................... 第六章系统测试与分析.....................................................测试过程.............................................................测试分析............................................................. 结论.................................................................. 参考文献..................................................................第一章绪论课题的背景及意义当今社会,手机已经成为人们工作生活中必不可少的一项通讯和娱乐工具,随着手机的不断更新,手机的各种高层服务和应用层出不穷。
这是本人自己用安卓编写的计算器,代码的优化可能有所问题,不过大家都在学习阶段,欢迎大家批评指正,还是上源码吧。
先来运行图package com.example.nanchen.exam_1_1;import android.content.DialogInterface;import android.support.v7.app.AlertDialog;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;import android.widget.Button;import android.widget.TextView;public class MainActivity extends AppCompatActivity implements View.OnClickListener{private Button btn0;private Button btn1;private Button btn2;private Button btn3;private Button btn4;private Button btn5;private Button btn6;private Button btn7;private Button btn8;private Button btn9;private Button btnAdd;private Button btnSub;private Button btnMul;private Button btnDiv;private Button btnDec;private Button btnEqual;private Button btnClear;private Button btnBackSpace;private TextView textView_result;double num1 = 0,num2 = 0,result = 0;//定义存储结果和两个操作数boolean isCheckEqu = false;//检测是否点击了等于int op = 0;//定义运算符boolean hasDec = false;boolean hasOp = false;@Overrideprotected void onCreate Bundle savedInstanceStatesuper.onCreate savedInstanceState;setContentView yout.activity_main;textView_result = TextView findViewById R.id.result;btn0 = Button findViewById R.id.btn0;btn1 = Button findViewById R.id.btn1;btn2 = Button findViewById R.id.btn2;btn3 = Button findViewById R.id.btn3;btn4 = Button findViewById R.id.btn4;btn5 = Button findViewById R.id.btn5;btn6 = Button findViewById R.id.btn6;btn7 = Button findViewById R.id.btn7;btn8 = Button findViewById R.id.btn8;btn9 = Button findViewById R.id.btn9;btnAdd = Button findViewById R.id.btn10;btnSub = Button findViewById R.id.btn11;btnMul = Button findViewById R.id.btn12;btnDiv = Button findViewById R.id.btn13;btnDec = Button findViewById R.id.btn14;btnEqual = Button findViewById R.id.btn15;btnClear = Button findViewById R.id.clear;btnBackSpace = Button findViewById R.id.backSpace;btn0.setOnClickListener this;btn1.setOnClickListener this;btn2.setOnClickListener this;btn3.setOnClickListener this;btn4.setOnClickListener this;btn5.setOnClickListener this;btn6.setOnClickListener this;btn7.setOnClickListener this;btn8.setOnClickListener this;btn9.setOnClickListener this;btnAdd.setOnClickListener this;btnSub.setOnClickListener this;btnDec.setOnClickListener this;btnDiv.setOnClickListener this;btnEqual.setOnClickListener this;btnMul.setOnClickListener this;btnClear.setOnClickListener this;btnBackSpace.setOnClickListener this;@Overridepublic void onClick View vswitch v.getIdcase R.id.btn0:if isCheckEqutextView_result.setText null;isCheckEqu=false;String myString0 =textView_result.getText.toString;if myString0.equals"0"myString0 = "";myString0 += "0";textView_result.setText myString0;break;case R.id.btn1:if isCheckEqutextView_result.setText null;isCheckEqu=false;String myString1 =textView_result.getText.toString;if myString1.equals"0"myString1 = "";myString1 += "1";textView_result.setText myString1;break;case R.id.btn2:if isCheckEqutextView_result.setText null;isCheckEqu=false;String myString2 =textView_result.getText.toString;if myString2.equals"0"myString2 = "";myString2 += "2";textView_result.setText myString2;break;case R.id.btn3:if isCheckEqutextView_result.setText null;isCheckEqu=false;String myString3 =textView_result.getText.toString;if myString3.equals"0"myString3 = "";myString3 += "3";textView_result.setText myString3;break;case R.id.btn4:if isCheckEqutextView_result.setText null;isCheckEqu=false;String myString4 =textView_result.getText.toString;if myString4.equals"0"myString4 = "";myString4 += "4";textView_result.setText myString4;break;case R.id.btn5:if isCheckEqutextView_result.setText null;isCheckEqu=false;String myString5 =textView_result.getText.toString;if myString5.equals"0"myString5 = "";myString5 += "5";textView_result.setText myString5;break;case R.id.btn6:if isCheckEqutextView_result.setText null;isCheckEqu=false;String myString6 =textView_result.getText.toString;if myString6.equals"0"myString6 = "";myString6 += "6";textView_result.setText myString6;break;case R.id.btn7:if isCheckEqutextView_result.setText null;isCheckEqu=false;String myString7 =textView_result.getText.toString;if myString7.equals"0"myString7 = "";myString7 += "7";textView_result.setText myString7;break;case R.id.btn8:if isCheckEqutextView_result.setText null;isCheckEqu=false;String myString8 =textView_result.getText.toString;if myString8.equals"0"myString8 = "";myString8 += "8";textView_result.setText myString8;break;case R.id.btn9:if isCheckEqutextView_result.setText null;isCheckEqu=false;String myString9 =textView_result.getText.toString;if myString9.equals"0"myString9 = "";myString9 += "9";textView_result.setText myString9;break;case R.id.btn10:if hasOpdoEqual;//显示出来当前的答案String myStringAdd =textView_result.getText.toString;if myStringAdd.equals nullreturn;num1 = Double.valueOf myStringAdd;textView_result.setText null;// 这里被清除了op = 1;isCheckEqu = false;hasDec = false;hasOp = true;break;case R.id.btn11:if hasOpdoEqual;String myStringSub =textView_result.getText.toString;if myStringSub.equals nullreturn;num1 = Double.valueOf myStringSub;textView_result.setText null;op = 2;isCheckEqu = false;hasDec = false;hasOp = true;break;case R.id.btn12:if hasOpdoEqual;String myStringMul =textView_result.getText.toString;if myStringMul.equals nullreturn;num1 = Double.valueOf myStringMul;textView_result.setText null;op = 3;isCheckEqu = false;hasDec = false;hasOp = true;break;case R.id.btn13:if hasOpdoEqual;String myStringDiv =textView_result.getText.toString;if myStringDiv.equals nullreturn;num1 = Double.valueOf myStringDiv;textView_result.setText null;op = 4;hasDec = false;isCheckEqu = false;hasOp = true;break;case R.id.btn14:if isCheckEqutextView_result.setText null;isCheckEqu=false;if hasDec//如果已经有小数点了,则弹出一个对话框AlertDialog.Builder builder = new AlertDialog.Builder MainActivity.this;builder.setTitle"警告";builder.setMessage"输入错误,一个数字不能有两个小数点!";builder.setNegativeButton"取消", new DialogInterface.OnClickListener@Overridepublic void onClick DialogInterface dialog, int which;builder.show;return;hasDec = true;String myString14 =textView_result.getText.toString;myString14 += ".";textView_result.setText myString14;break;case R.id.btn15:doEqual;hasOp = false;break;case R.id.backSpace:String myString =textView_result.getText.toString;trytextView_result.setText myString.substring0,myString.length -1;catch Exception etextView_result.setText"0";break;case R.id.clear:textView_result.setText"0";break;default:break;/*** 按下等于*/private void doEqualStringmyStringEqu=textView_result.getText.toString;if myStringEqu.equals nullreturn;num2=Double.valueOf myStringEqu;textView_result.setText null;switch opcase 0:result=num2;break;case 1:result=num1+num2;break;case 2:result=num1-num2;break;case 3:result=num1*num2;break;case 4:result=num1/num2;break;default:result=0;break;textView_result.setText String.valueOf result;isCheckEqu=true;<?xml version="1.0" encoding="utf-8"?>LinearLayoutxmlns:android="/apk/res/android"xmlns:tools="/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"tools:context="com.example.nanchen.exam_1_1.MainActivity"<!--显示结果-->LinearLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"TextViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:id="@+id/result"android:gravity="end"android:textSize="40sp"android:text="@string/zero"LinearLayoutLinearLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:orientation="horizontal"android:layout_weight="1"Buttonandroid:layout_width="0dp"android:layout_weight="1"android:layout_height="wrap_content"android:text="@string/clear"android:id="@+id/clear"android:textAllCaps="false"android:gravity="center"android:textSize="25sp"Buttonandroid:layout_width="0dp"android:layout_weight="1"android:layout_height="wrap_content"android:text="@string/backspace"android:id="@+id/backSpace"android:textAllCaps="false"android:gravity="center"android:textSize="25sp" LinearLayout<!--789/-->LinearLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"Buttonandroid:layout_width="0dp"android:text="@string/seven"android:id="@+id/btn7"android:textSize="30sp"android:gravity="center"android:layout_height="wrap_content"android:layout_weight="1"Buttonandroid:layout_width="0dp"android:text="@string/eight"android:id="@+id/btn8"android:textSize="30sp"android:gravity="center"android:layout_height="wrap_content"android:layout_weight="1"Buttonandroid:layout_width="0dp"android:text="@string/nine"android:id="@+id/btn9"android:textSize="30sp"android:gravity="center"android:layout_height="wrap_content"android:layout_weight="1"Buttonandroid:layout_width="0dp"android:text="@string/del"android:id="@+id/btn13"android:textSize="30sp"android:gravity="center"android:layout_height="wrap_content"android:layout_weight="1" LinearLayout<!--456*-->LinearLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"Buttonandroid:layout_width="0dp"android:text="@string/four"android:id="@+id/btn4"android:textSize="30sp"android:gravity="center"android:layout_height="wrap_content"android:layout_weight="1"Buttonandroid:layout_width="0dp"android:text="@string/five"android:id="@+id/btn5"android:textSize="30sp"android:gravity="center"android:layout_height="wrap_content"android:layout_weight="1"Buttonandroid:layout_width="0dp"android:text="@string/six"android:id="@+id/btn6"android:textSize="30sp"android:gravity="center"android:layout_height="wrap_content"android:layout_weight="1"Buttonandroid:layout_width="0dp"android:text="@string/mul"android:id="@+id/btn12"android:textSize="30sp"android:gravity="center"android:layout_height="wrap_content"android:layout_weight="1" LinearLayout<!--123- -->LinearLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"Buttonandroid:layout_width="0dp"android:text="@string/one"android:textSize="30sp"android:id="@+id/btn1"android:gravity="center"android:layout_height="wrap_content"android:layout_weight="1"Buttonandroid:layout_width="0dp"android:text="@string/two"android:id="@+id/btn2"android:textSize="30sp"android:gravity="center"android:layout_height="wrap_content"android:layout_weight="1"Buttonandroid:layout_width="0dp"android:text="@string/three"android:id="@+id/btn3"android:textSize="30sp"android:gravity="center"android:layout_height="wrap_content"android:layout_weight="1"Buttonandroid:layout_width="0dp"android:text="@string/sub"android:id="@+id/btn11"android:textSize="30sp"android:gravity="center"android:layout_height="wrap_content"android:layout_weight="1" LinearLayout<!--0.=+-->LinearLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"Buttonandroid:layout_width="0dp"android:text="@string/zero1"android:id="@+id/btn0"android:textSize="30sp"android:gravity="center"android:layout_height="wrap_content"android:layout_weight="1"Buttonandroid:layout_width="0dp"android:text="@string/dec"android:id="@+id/btn14"android:textSize="30sp"android:gravity="center"android:layout_height="wrap_content"android:layout_weight="1"Buttonandroid:layout_width="0dp"android:text="@string/equal"android:id="@+id/btn15"android:textSize="30sp"android:gravity="center"android:layout_height="wrap_content"android:layout_weight="1"Buttonandroid:layout_width="0dp"android:text="@string/add"android:id="@+id/btn10"android:textSize="30sp"android:gravity="center"android:layout_height="wrap_content"android:layout_weight="1"LinearLayoutLinearLayoutandroid:layout_weight="4"android:orientation="vertical"android:layout_width="match_parent"android:layout_height="0dp"TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:textSize="20sp"android:text="@string/string1"TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/string2"android:textSize="20sp"LinearLayoutLinearLayout。
Android计步模块实例代码(类似微信运动)最近在项⽬中研究计步模块,每天0点开始记录当天的步数,类似微信运动。
碰到了不少坑今天有时间整理出来给⼤家看看。
做之前在google、baidu、github上搜了个遍没找到好的,⼤多数都是需要在后台存活,需要后台Service。
对于现在的各⼤⼿机⼚商为了提⾼电池的续航⾥程(省电),基本上AlertManager、android.intent.action.BOOT_COMPLETED、后台Service都是被⼲掉的。
后台保活策略Service,基本上没什么⽤,被⼿机系统⼲掉只是时间问题,所以我认为最好也不要去做,就算后台存活了,⽤户看到这个app⾮常费电也会被删除的。
⽬前android计步有两种⽅式系统计步芯⽚在Android4.4版本之后,部分机型实现了Sensor.TYPE_STEP_COUNTER传感器,⽤于纪录⽤户⾏⾛的步数。
从⼿机开机开始纪录,⼿机关机时重置为0。
这个记步芯⽚是系统级别的,相对之前⽼版本的传感器记步,性能有⼀些优化:不会因为App单独⽤了记步的功能⽽额外耗电系统芯⽚记步是持续的,能够优化部分机型后台不记步的问题。
加速度传感器计算⽅式加速度传感器⾮常耗电,导致App的耗电量很⾼,影响⽤户体验。
需要后台实时运⾏才能实现记步的功能,如果App进程被系统或者安全软件杀死,导致记步功能没办法使⽤根据以上两种⽅式实现计步,⼿机提供计步传感器就使⽤Sensor.TYPE_STEP_COUNTER⽅式(app后台关闭也可以计步),如果不提供就使⽤SensorManager.SENSOR_DELAY_UI⽅式(app需要保持后台运⾏)。
项⽬结构:计步Service使⽤单独进程,所以使⽤到进程间通信aidl,todaystepcounterlib为库⽂件⽤于在单独进程中实现计步算法,app 依赖todaystepcounterlib项⽬获取当前步数展⽰。
毕业论文题目基于安卓平台的手机计步器的设计摘要Android是一个针对移动设备的操作系统和软件平台,随着智能手机的兴起,渐渐成为了占有市场最大比重的移动平台操作系统,同时也越发地受到广大用户的青睐。
Android采用 Linux 内核,由 Google 和开放手机联盟于2007年11月5日发布。
容许使用 Java语言来开发和管理代码。
作为一个年轻并且流行的移动应用平台,目前android软件的应用面还是比较广泛的,比如聊天,通讯,上网等等,但涉及传感器方面的应用软件还比较少。
本文在分析讨论Android手机软件开发原理的同时,针对智能手机用户日常使用的实际情况,对用户手机的日常功能需求进行调查。
发现对于经常走路上班或者锻炼的朋友来说拥有一款精美、功能齐全的计步器是非常必要的。
将精确计量和智能运行技术完美结合,只需开启软件,通过感应器传来的信息,App能够变化算法,测得你的走路步数,速度以及消耗的卡路里量与行走历程。
一款合适的计步器在无形中会量化用户的健身效果,帮助用户坚持锻炼以达到更好的健身效果。
关键词Android 智能手机平台计步器 JavaTitle The design of mobile phone pedometer based on the android platformAbstractAndroid is an operating system and software platform for mobile devices. With the development of Smartphone, it gradually became the biggest proportion in the market of mobile operating system. At the same time, it became more and more popular among users. Android uses the Linux kernel, announced on November 5, 2007 by Google and the open handset alliance, and it allow to use Java language to develop and manage the code. As a young and popular mobile application platform, the application of android is relatively wide; such as chat, communication and internet. However, the application of sensors is less. The thesis of this essay is to analyze and discuss the principle of software development of Android mobile phone. Also, the another purpose in this essay is to conduct an investigation in the daily functional demand for mobile phone users based on the situation of daily uses of smart phone users. The research shows that it is very important to have a fully functional pedometer for people who often walk to work or exercise. The pedometer makes a perfect combination of accurate measurement and intelligent operational technology, when the software are ready to run, it can use the massage which acquire from sensor to calculate the step frequency ,speed, the consumption of calories and walking journey of your walk. An appropriate pedometer can quantify user’s fitness effect in potentially; in this way it can make users to keep exercising in order to achieve better fitness effect.Keywords android smartphone platform java pedometer目录1.前言 (1)1.1智能手机系统开发背景 (1)1.2课题的目的与意义 (2)1.3本文主要研究内容 (2)2.相关技术介绍 (4)2.1开发工具及环境简介 (4)2.1.1 开发工具 (4)2.1.2 开发环境 (5)2.2ANDROID SDK常见公共类库介绍 (6)2.2.1 Android的传感器 (6)2.2.2 Android界面Activity介绍 (6)3.系统需求分析 (8)3.1可行性研究 (8)3.1.1 经济可行性 (8)3.1.2 技术可行性 (8)3.1.3 操作可行性 (9)3.2性能需求分析 (10)3.2.1 实用性原则 (10)3.2.2 可扩展性与可维护性原则 (10)3.2.3 安全可靠性原则 (11)3.2.4 用户界面美观原则 (11)3.3 数据需求分析 (13)4.系统设计 (14)4.1系统总体结构设计 (14)4.2 系统静态模型设计 (15)5.系统实现 (16)5.1布局界面的设计 (16)5.1.1主界面的设计 (16)5.1.2设置界面的设计 (17)5.2各功能的实现 (18)5.2.1 计步开始及暂停 (18)5.2.2 记录数据清零 (18)5.2.3 设置步长 (18)5.2.4 设置体重 (19)5.2.5 设置运动状态 (19)6.系统测试 (20)6.1测试开始停止模块 (20)6.1.1 测试准备 (20)6.1.2测试过程 (20)6.2测试总结 (23)5.结论 (24)致谢 (25)参考文献 (26)附录 (27)1.前言1.1 智能手机系统开发背景当今社会,手机已经成为人们工作生活中必不可少的一项通讯和娱乐工具,随着手机的不断更新,手机的各种高层服务和应用层出不穷。
摘要随着智能手机市场的不断扩大,智能手机应用开发己经展现出其强大的市场价值。
Android最具创新的特点是其开放性体系架构,这使得Android平台具体无限的吸引力。
近来越来越多的人对自身健康问题感到关注,运动健身类软件也逐渐成为了移动互联网业务的一个主要应用方向。
本文以运动健身作为研究方向,设计并实现一款基于Android智能手机的计步应用软件。
该应用软件通过手机GPS功能来获取用户实时的经纬度信息,借助地球球面两点间的距离公式计算用户的运动距离,从而测得用户所走的步数、速度以及消耗的热量。
此外,该软件包括使用SQLite数据库查询用户的历史运动信息以及设置运动者的身高、体重和运动目标等参数的功能。
本系统界面友好、操作便捷,具有良好的可扩展性和可维护性;系统经过测试,可以稳定运行,对于日常走路上班或者锻炼的人来说非常合适,方便人们及时掌握自己锻炼的情况,达到高效锻炼的效果。
关键词:Android; GPS;计步器; SQLite;运动健身ABSTRACTWith the continuous expansion of the smart Phone market,the smartPhone applications development has demonstrated its strong market value.Android's most innovative feature is its open architecture, which makes the Android platform unlimited appeal.Recently, more and more people are concerned about their own health problems, sports and fitness class software is becoming a major application direction of the mobile Internet business.Therefore, the context make use of the sports and fitness as its research direction to design and implement the pedometer application software which based on Android-based smartphone.The core functionality is that through the GPS function of mobile phones ,it can get the latitude and longitude information in real time about the user, use the distance between two points of the Earth's spherical formula to calculate the user's movement distance, which used to measure the number of steps to go, speed and calories burned. Besides,this software’s function includs that using the SQLite database to query the history information about user and set the height,weight and target of step sports about the user.The system’s interface is quite friendly and easy to handle the system,.it has good scalability and maintainability; the system has been tested and operated very well, the software is very suitable for the people who walks to work daily or likes exercising themselves, it is convenientfor people to know their exercise information at any time and in any place ,so that we can achieve our purpose to hava a high efficiency exercise.Keywords:Android; GPS; pedometer; SQLite; fitness目录1 绪论 (3)1.1 研究背景 (3)1.2 研究目的和意义 (3)1.3 研究内容 (4)1.4 本文结构 (4)2 相关技术综述 (5)2.1 Android (5)2.1.1 Android简介 (5)2.1.2 Android特性 (6)2.1.3 Android 基本框架 (6)2.1.4 Android系统的四大组件 (8)2.2 开发环境介绍 (9)2.2.1 Eclipse简介 (9)2.2.2 ADT (10)2.2.3 Android SDK (10)2.2.4 SQLite数据库 (10)2.3 GPS相关理论技术知识 (10)2.3.1 GPS定位原理 (10)2.3.2 Android中GPS类简介 (11)3 需求分析 (12)3.1 功能需求 (12)3.2 数据的需求分析 (13)3.3 系统运行环境 (14)4 系统设计 (14)4.1 功能模块设计 (14)4.1.1 计步功能 (14)4.1.2 查询运动信息功能 (16)4.1.3 设置参数功能 (18)4.1.4 退出系统功能 (19)4.2 数据设计 (20)5 系统实现 (21)5.1 Android环境搭建 (21)5.2 软件结构设计 (23)5.3 计步功能 (25)5.4 查询运动信息功能 (29)5.5 设置参数功能 (30)5.6 退出系统功能 (31)6 结束语 (33)参考文献 (34)附录 (35)致谢 (56)1绪论1.1研究背景自上世纪80年代第一部手机诞生以来,随着计算机技术的进步,手机也经历了从模拟器到GSM、2.5G再到今天的3G手机如此一个发展历程[1]。
专业工程综合实训设计报告目录第一章绪论...............................................................课题的背景及意义......................................................系统框架.............................................................. 第二章系统分析...........................................................系统可行性分析.......................................................功能可行性分析...................................................运行环境可行性分析...............................................开发环境简介.........................................................Java Development kit(JDK)介绍..................................Android SDK 介绍.................................................Eclipse开发工具介绍.............................................Android Development Tools(ADT)介绍............................. 第三章 Android开发常用到的技术及环境搭建.................................Android开发常用到的技术.............................................Activity.........................................................Service..........................................................Content Provider 内容提供者......................................Intent 信使......................................................环境搭建..............................................................安装JDK..........................................................安装Eclipse......................................................Android SDK安装................................................ADT安装........................................................ 第四章手机计步器的设计与实现.............................................计步器功能的设计......................................................计步器功能的实现......................................................计步开始及暂停...................................................复位键...........................................................设置步长..........................................................设置体重..........................................................历史记录的查看及删除.............................................. 第五章计步器的界面效果...................................................用户界面..............................................................设置界面..............................................................历史界面..............................................................日历选择界面..........................................................用户离开界面.......................................................... 第六章系统测试与分析.....................................................测试过程.............................................................测试分析............................................................. 结论.................................................................. 参考文献..................................................................第一章绪论课题的背景及意义当今社会,手机已经成为人们工作生活中必不可少的一项通讯和娱乐工具,随着手机的不断更新,手机的各种高层服务和应用层出不穷。
现在智能手机可谓是爆发式增长,与此同时传统手机在不断地消失,诺基亚就是在这样的环境中受到了重创。
现在主要有三个使用率和关注度最高的手机平台,分别是:Android,ios和windows phone平台,在这三个平台中Android的占有率最高。
自2007年11月Google公司发布Android系统以来,短短几年时间,Android已经占据了智能手机市场的半壁江山,成为目前最为炙手可热的智能手机操作系统。
Android走进了越来越多人的生活,成为他们获取信息的主要平台。
Android平台对于Google和用户的意义不在于手机本身,而在于为了推动移动互联网产业链的迅速成型。
具有开源性的Android手机平台与之前Symbian、windows mobile等操作系统不同,它们收取高额的授权费用,而Android不需要,这样使得应用开发成本大大降低;也正是由于它的源代码是开放的,使得开发者可以随心所欲的开发应用。
同时,手机生产商和软件开发商也能够在这里得到利润,手机软件得到有效的维护协调发展。
这正是Google发布Android平台的意义,也是Android平台的使命所在。
同时目前搭载Android平台的应用有很多,但针对传感器而开发的应用市场上还不多见。
本应用正是针对Android手机内置的加速度传感器而特别设计的应用。
所以鉴于移动端应用开发是目前软件开发行业正在兴起并会越来越炙手可热的一个分支,并且针对传感器的开发相对空白我选择了研究此课题。
系统框架在设计一款软件时一般都会把它分成几个模块,在模块的基础上还会再分小模块,这样就达到了软件模块化设计的要求,然后再对各个小模块进行详细设计和编写,采用模块化的管理方式可以使软件结构更清晰,也使得软件的管理更有秩序,使别人容易理解和阅读,但是这些模块也要根据别的模块来设计和约束,不能随便设计脱离框架,设计完成后需要把每个设计完成的模块根据总体框架结合起来。
根据本软件的功能需求,将本软件分为以下几个功能模块,如图 1-1所示:图1-1 整体框架图第二章系统分析系统可行性分析可行性分析(Feasibility?Analysis)也称为可行性研究,是在系统调查的基础上,针对刚刚开发打算进一步应用的系统的必要性和可能性的分析和研究。
可行性研究的目的主要在于,用最小的代价在尽可能短的时间内确定问题是否能够解决。
[1]该阶段通过对系统总目标的初步调研与分析,提出可行性方案并进行论证。
功能可行性分析1、计步功能:根据用户设置的步长和体重,估算用户步行运动所消耗的热量。
当距离发生改变时在前台界面上刷新用户步行的步数、距离、和消耗的卡路里;该计步功能还实现了Notification后台运行的功能。
2、设置参数功能:设置用户的步长、体重2个参数信息。
通过设置体重可以估算出不同体重的人运动所消耗的卡路里量。
3、退出系统功能:当用户想终止计步软件时,可以点击退出菜单后退出本系统。
4、历史记录功能: 用户可以查看以往的历史记录。
5、保存功能:有户可以保存当天的运动量,以便之后查看。
运行环境可行性分析本软件是在windows 7 操作系统中,利用Eclipse 开发工具搭载Android SDK工具包,结合Android手机自带的sqlite数据库进行开发。
开发环境简介Java Development kit(JDK)介绍JDK是Java语言的软件开发工具包。
本应用用的是JDK的J2ME版,它主要用于移动设备、嵌入式设备上的Java应用程序。
没有JDK的话,无法编译Java程序,所以这是开发Java 程序必须安装的工具。
Android SDK 介绍SDK(software development kit)软件开发工具包。
被软件开发工程师用于为特定的软件包、软件框架、硬件平台、操作系统等建立应用软件的开发工具的集合。
因此,Android SDK 指的是Android专属的软件开发工具包。
Eclipse开发工具介绍Eclipse是一个开放源代码的、基于插件的可扩展性平台。
也可以说它只是一个框架和一组服务,用于通过插件组件构建开发环境。