安卓程序开发实验七

本科学生实验(实践)报告
    系:教育信息技术学院
实验课程:移动智能设备程序设计
实验项目:较复杂的应用开发
指导老师:王洪江
开课时间: 2014  酵母分离机 2015年度第 学期
    业:教育技术学(多媒体与网络技术方向)
班  级:12级多媒体2
华南师范大学教务处
华南师范大学实验报告
学生姓名  陈兆峰          20122802011金属表面镜面处理
专业 教育技术学(多媒体与网络技术)
年级、班级 12级多媒体2陶瓷运输
课程名称移动智能设备程序设计实验项目 实验七 较复杂的应用开发
实验类型 验证 设计综合 实验时间 2015    5 22
实验指导老师  王洪江      实验评分                   
一、实验目的、目标
1. 了解Google APIGoogle Voice, Map等;
2. 了解各种传感器,多点触摸;
3. 了解 定位技术GPS, AGPS
4. 了解Widget
二、实验内容
1.基于AndroidGPS定位
三、实验过程与步骤
1 Google Android Api里面的TelephonyManager的管理。
TelephonyManager tm = (TelephonyManager)
getSystemService(Context.TELEPHONY_SERVICE);
通过这个方式就可以得到TelephonyManager接口。
这个接口的源代码可以通过设置在项目里面查看,这里不具体附上了。
得到载人行李箱TelephonyManager后,由于针对不同的运营商,代码有所不同,所以需要判断getNetworkType()
在源代码里面有如下的类型定义
    /** Network type is unknown */
    public static final int NETWORK_TYPE_UNKNOWN = 0;
    /** Current network is GPRS */
    public static final int NETWORK_TYPE_GPRS = 1;
    /** Current network is EDGE */
    public static final int NETWORK_TYPE_EDGE = 2;
    /** Current network is UMTS */
    public static final int NETWORK_TYPE_UMTS = 3;
    /** Current network is CDMA: Either IS95A or IS95B*/
    public static final int NETWORK_TYPE_CDMA = 4;
    /** Current network is EVDO revision 0*/
    public static final int NETWORK_TYPE_EVDO_0 = 5;
    /** Current network is EVDO revision A*/
    public static final int NETWORK_TYPE_EVDO_A = 6;
    /** Current network is 1xRTT*/
    public static final int NETWORK_TYPE_1xRTT = 7;
    /** Current network is HSDPA */
    public static final int NETWORK_TYPE_HSDPA = 8;
    /** Current network is HSUPA */
    public static final int NETWORK_TYPE_HSUPA = 9;
    /** Current network is HSPA */
    public static final int NETWORK_TYPE_HSPA = 10;
2 联通、移动、电信不同制式在获取位置的代码区别。
这部分是我实际测试出来的,经过无数次的拆机,放卡,才实现了不同制式的完美实现。
代码如下:
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
int type = tm.getNetworkType();
//中国电信为CTC
//NETWORK_TYPE_EVDO_A是中国电信3GgetNetworkType
//NETWORK_TYPE_CDMA电信2GCDMA
if (type == TelephonyManager.NETWORK_TYPE_EVDO_A || type == TelephonyManager.NETWORK_TYPE_CDMA || type ==TelephonyManager.NETWORK_TYPE_1xRTT)马氏体耐热钢
{
agps}
//移动2G + CMCC + 2
//type = NETWORK_TYPE_EDGE
else if(type == TelephonyManager.NETWORK_TYPE_EDGE)
{
}
/
/联通的2G经过测试 China Unicom  1 NETWORK_TYPE_GPRS
else if(type == TelephonyManager.NETWORK_TYPE_GPRS)
{
}
else
{
tv.setText("Current Not Support This Type.");
}
3 通过的基本信息,通过Google Gears获取对应的GPS经纬度。
这部分前面的两篇文章都有提到,代码参考了网友们的代码,感谢感谢。
private Location callGear(ArrayList cellID) {
        if (cellID == null) return null;
        DefaultHttpClient client = new DefaultHttpClient();
        HttpPost post = new HttpPost(
                "le/loc/json");
        JSONObject holder = new JSONObject();
        try {
            holder.put("version", "1.1.0");
            holder.put("host", "le");
            holder.put("home_mobile_country_code", (0).mobileCountryCode);
            holder.put("home_mobile_network_code", (0).mobileNetworkCode);
            holder.put("radio_type", (0).radioType);
            holder.put("request_address", true);
            if ("460".(0).mobileCountryCode))
                holder.put("address_language", "zh_CN");
            else
                holder.put("address_language", "en_US");
            JSONObject data,current_data;
            JSONArray array = new JSONArray();
            current_data = new JSONObject();
            current_data.put("cell_id", (0).cellId);
            current_data.put("location_area_code", (0).locationAreaCode);
            current_data.put("mobile_country_code", (0).mobileCountryCode);
            current_data.put("mobile_network_code", (0).mobileNetworkCode);
            current_data.put("age", 0);
            array.put(current_data);
            if (cellID.size() > 2) {
                for (int i = 1; i < cellID.size(); i++) {
                    data = new JSONObject();
                    data.put("cell_id", (i).cellId);
                    data.put("location_area_code", (i).locationAreaCode);

本文发布于:2024-09-22 00:58:57,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/4/334108.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:实验   代码   移动   技术   基站
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议