日本a√视频在线,久久青青亚洲国产,亚洲一区欧美二区,免费g片在线观看网站

        <style id="k3y6c"><u id="k3y6c"></u></style>
        <s id="k3y6c"></s>
        <mark id="k3y6c"></mark>
          
          

          <mark id="k3y6c"></mark>

          新聞中心

          EEPW首頁 > 汽車電子 > 設(shè)計應(yīng)用 > 基于Android的位置實時監(jiān)控系統(tǒng)的設(shè)計與實現(xiàn)

          基于Android的位置實時監(jiān)控系統(tǒng)的設(shè)計與實現(xiàn)

          作者:張維文 孫耀杰 李利娟 時間:2015-04-23 來源:電子產(chǎn)品世界 收藏

            2.3 程序?qū)崿F(xiàn)

          本文引用地址:http://yuyingmama.com.cn/article/273085.htm

            一是定位功能的實現(xiàn)。充分利用智能手機內(nèi)置定位模塊,基于Eclipse開發(fā)平臺通過程序的調(diào)用,實現(xiàn)定位功能,手機運行結(jié)果如圖4所示。其實現(xiàn)代碼如下:

            /**
            * 將獲得的位置信息顯示出來
            * @param location
            */
            private void setLocation(Location location){
            if (location != null) {
            String latitudeStr = Double.toString(location.getLatitude());//經(jīng)度
            String longitudeStr = Double.toString(location.getLongitude());//緯度
            String altitudeStr = Double.toString(location.getAltitude());//海拔
            // 獲取當前時間
            SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",Locale.CHINA);
            String dateStr = sDateFormat.format(new java.util.Date());
            gpsTime.setText(dateStr);
            if (latitudeStr != null && !latitudeStr.equals("")) {
            latitude.setText(latitudeStr);
            }
            if (longitudeStr != null && !longitudeStr.equals("")) {
            longitude.setText(longitudeStr);
            }
            if (altitudeStr != null && !altitudeStr.equals("")) {
            altitude.setText(altitudeStr);
            }
            } else {
            Log.v("location", "location為空");
            }
            }

            二是經(jīng)緯度信息發(fā)送功能的實現(xiàn)。根據(jù)事先設(shè)置好的監(jiān)控端手機號碼,按照發(fā)送頻率(時間間隔),將經(jīng)緯度發(fā)送到監(jiān)控端。其實現(xiàn)代碼如下:

            /**
            * 發(fā)送短信
            * @param smsContent 短信內(nèi)容
            */
            private void sendSMS(String smsContent){
            //獲取短信管理器
            SmsManager smsManager = SmsManager.getDefault();
            //拆分短信內(nèi)容
            List divideContents = smsManager.divideMessage(smsContent);
            if (curPhoneNum == null || curPhoneNum.equals("")) {
            new AlertDialog.Builder(MainActivity.this).setTitle("警告").setMessage("您還未設(shè)置目標電話號碼").create().show();
            return;
            }
            //發(fā)送短信
            for (String text : divideContents) {
            smsManager.sendTextMessage(curPhoneNum, null, text, null, null);
            }
            }



          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉