当前位置:  编程技术>移动开发
本页文章导读:
    ▪透过gps,wifi,基站定位获取当前位置        通过gps,wifi,基站定位获取当前位置 private Location getCurrentLocationGPS() {        Criteria criteria = new Criteria();        criteria.setAccuracy(Criteria.ACCURACY_FINE);        criteria.setAltitudeRequired(false.........
    ▪ 彩信发送(透过手机本身)        彩信发送(通过手机本身) private void sendMessage(){ Intent intent = new Intent(Intent.ACTION_SEND,Uri.parse("mms://")); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Intent.EXTRA_STREAM, Uri.parse('file:///sd.........
    ▪ 三个简略混淆的jquery键盘事件       三个容易混淆的jquery键盘事件 1、keydown()      keydown事件会在键盘按下时触发. 2、keyup()      keyup事件会在按键释放时触发,也就是你按下键盘起来后的事件 3、keypress()      keypress事件会.........

[1]透过gps,wifi,基站定位获取当前位置
    来源: 互联网  发布时间: 2014-02-18
通过gps,wifi,基站定位获取当前位置
private Location getCurrentLocationGPS() {
        Criteria criteria = new Criteria();
        criteria.setAccuracy(Criteria.ACCURACY_FINE);
        criteria.setAltitudeRequired(false);
        criteria.setBearingRequired(false);
        criteria.setCostAllowed(true);
        criteria.setPowerRequirement(Criteria.POWER_LOW);
        String locationProvider = locationManager.getBestProvider(criteria,
                true);

        Location location = locationManager
                .getLastKnownLocation(locationProvider);

        return location;
    }

    // 根据wifi获取当前位置
    private Location getCurrentLocationWifi(Context context) {
        Location location=null;
        LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        try
        {
            WifiManager wifiManager=(WifiManager)context.getSystemService(Context.WIFI_SERVICE);
            if(wifiManager.isWifiEnabled())
            {
             location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
            }
        }
        catch(Exception e)
        {
        }
       
       
       
        return location;
    }

    // 根据基站获取当前的位置
    private Location getCurrentLocationAGPS() {
        Location location = null;

        if (telephonyManager.getCellLocation() == null) {

        }
        GsmCellLocation gcl = (GsmCellLocation) telephonyManager
                .getCellLocation();

        int cid = gcl.getCid();

        int lac = gcl.getLac();

        int mcc = Integer.valueOf(telephonyManager.getNetworkOperator()
                .substring(0,

                3));

        int mnc = Integer.valueOf(telephonyManager.getNetworkOperator()
                .substring(3,

                5));

        try {

            // 组装JSON查询字符串

            JSONObject holder = new JSONObject();

            holder.put("version", "1.1.0");

            holder.put("host", "maps.google.com");

            // holder.put("address_language", "zh_CN");

            holder.put("request_address", true);

            JSONArray array = new JSONArray();

            JSONObject data = new JSONObject();
            data.put("cell_id", cid); // 25070
            data.put("location_area_code", lac);// 4474
            data.put("mobile_country_code", mcc);// 460

            data.put("mobile_network_code", mnc);// 0
            array.put(data);

            holder.put("cell_towers", array);

            // 创建连接,发送请求并接受回应

            DefaultHttpClient client = new DefaultHttpClient();
            HttpPost post = new HttpPost("http://www.google.com/loc/json");

            StringEntity se = new StringEntity(holder.toString());

            post.setEntity(se);

            HttpResponse resp = client.execute(post);

            HttpEntity entity = resp.getEntity();

            BufferedReader br = new BufferedReader(

            new InputStreamReader(entity.getContent()));

            StringBuffer resultStr = new StringBuffer();

            String readLine = null;

            while ((readLine = br.readLine()) != null) {

                resultStr.append(readLine);

            }

            JSONObject jsonResult = new JSONObject(resultStr.toString());
            JSONObject jsonLocation = jsonResult.getJSONObject("location");
            double jsonLat = jsonLocation.getDouble("latitude");
            double jsonLon = jsonLocation.getDouble("longitude");

            location = new Location("AGPS");
            location.setLatitude(jsonLat);
            location.setLongitude(jsonLon);

        } catch (Exception e) {

            // TODO: handle exception

        }

        return location;
    }

    
[2] 彩信发送(透过手机本身)
    来源: 互联网  发布时间: 2014-02-18
彩信发送(通过手机本身)
private void sendMessage(){

    	Intent intent = new Intent(Intent.ACTION_SEND,Uri.parse("mms://"));
    	intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    	intent.putExtra(Intent.EXTRA_STREAM, Uri.parse('file:///sdcard/image.png'));
    	intent.putExtra("sms_body", "发送给老婆的100字!!");
    	intent.putExtra("subject", "发送给老婆的100字!!");
    	intent.putExtra(Intent.EXTRA_TEXT, "222");
    	intent.setType("image/png");
    	intent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
    	startActivity(intent);
    }

    
[3] 三个简略混淆的jquery键盘事件
    来源: 互联网  发布时间: 2014-02-18
三个容易混淆的jquery键盘事件

1、keydown()

     keydown事件会在键盘按下时触发.

2、keyup()

     keyup事件会在按键释放时触发,也就是你按下键盘起来后的事件

3、keypress()

     keypress事件会在敲击按键时触发,我们可以理解为按下并抬起同一个按键


    
最新技术文章:
▪Android开发之登录验证实例教程
▪Android开发之注册登录方法示例
▪Android获取手机SIM卡运营商信息的方法
▪Android实现将已发送的短信写入短信数据库的...
▪Android发送短信功能代码
▪Android根据电话号码获得联系人头像实例代码
▪Android中GPS定位的用法实例
▪Android实现退出时关闭所有Activity的方法
▪Android实现文件的分割和组装
▪Android录音应用实例教程
▪Android双击返回键退出程序的实现方法
▪Android实现侦听电池状态显示、电量及充电动...
▪Android获取当前已连接的wifi信号强度的方法
▪Android实现动态显示或隐藏密码输入框的内容
▪根据USER-AGENT判断手机类型并跳转到相应的app...
▪Android Touch事件分发过程详解
▪Android中实现为TextView添加多个可点击的文本
▪Android程序设计之AIDL实例详解
▪Android显式启动与隐式启动Activity的区别介绍
▪Android按钮单击事件的四种常用写法总结
▪Android消息处理机制Looper和Handler详解
▪Android实现Back功能代码片段总结
▪Android实用的代码片段 常用代码总结
▪Android实现弹出键盘的方法
▪Android中通过view方式获取当前Activity的屏幕截...
▪Android提高之MediaPlayer播放网络视频的实现方法... iis7站长之家
▪Android提高之多方向抽屉实现方法
▪Android提高之MediaPlayer播放网络音频的实现方法...
▪Android提高之MediaPlayer播放网络视频的实现方法...
▪Android提高之手游转电视游戏的模拟操控
 


站内导航:


特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3