zoukankan      html  css  js  c++  java
  • GPS技术(一)

     1 //获取所有的provider
     2 public class MainActivity extends ActionBarActivity {
     3     ListView mprovider;
     4     LocationManager mlManager;
     5 
     6     @Override
     7     protected void onCreate(Bundle savedInstanceState) {
     8         super.onCreate(savedInstanceState);
     9         setContentView(R.layout.fragment_main);
    10         mprovider = (ListView) findViewById(R.id.listView1);
    11         // 获得LocationManager对象
    12         mlManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    13         // 获取所有的Locationprovider的名称
    14         List<String> providerNames = mlManager.getAllProviders();
    15 
    16         ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
    17                 android.R.layout.simple_list_item_1, providerNames);
    18         mprovider.setAdapter(adapter);
    19     }
    20 
    21 }

     1 //根据条件获得Locationprovider
     2 public class MainActivity extends ActionBarActivity {
     3     ListView mprovider;
     4     LocationManager mlManager;
     5 
     6     @Override
     7     protected void onCreate(Bundle savedInstanceState) {
     8         super.onCreate(savedInstanceState);
     9         setContentView(R.layout.fragment_main);
    10         mprovider = (ListView) findViewById(R.id.listView1);
    11         mlManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    12         // 创建一个LocationProvider的过滤条件
    13         Criteria criteria = new Criteria();
    14         // 设置要求LocationProvider必须是免费的
    15         criteria.setCostAllowed(false);
    16         // 设置要求ocationProvider能提供高度信息----测海拔
    17         criteria.setAltitudeRequired(true);
    18         // 设置要求ocationProvider能提供方向信息----方向
    19         criteria.setBearingRequired(true);
    20         List<String> providerName = mlManager.getProviders(criteria, true);
    21         ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
    22                 android.R.layout.simple_list_item_1, providerName);
    23         mprovider.setAdapter(adapter);
    24     }
    25 
    26 }
  • 相关阅读:
    @XmlAccessorType @XmlType 详解
    eclipse properties 文件查看和编辑插件 Properties Editor
    对象设计解耦的方法IOC和DI
    J2EE7与Servlet3.x
    关于maven
    Spring版本功能变更&Spring4.x的新特性
    2017第37周三
    Java线程池
    Java并发包
    Java内部类
  • 原文地址:https://www.cnblogs.com/my334420/p/6919805.html
Copyright © 2011-2022 走看看