Android 打开 GPS 导航并获取位置信息
2010-10-19 17:18:28 来源:WEB开发网<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.UPDATE_DEVICE_STATS"></uses-permission>
1 import android.app.Activity;
2 import android.content.Context;
3 import android.location.Criteria;
4 import android.location.Location;
5 import android.location.LocationListener;
6 import android.location.LocationManager;
7 import android.os.Bundle;
8 import android.util.Log;
9
10 public class audio extends Activity
11 {
12
13 /** Called when the activity is first created. */
14 LocationManager locationManager;
15 LocationListener llistener;
16 String provider;
17
18 public void onCreate(Bundle savedInstanceState)
19 {
20 super.onCreate(savedInstanceState);
21 setContentView(R.layout.main);
22
23 Criteria criteria = new Criteria();
24 criteria.setAccuracy(Criteria.ACCURACY_FINE);
25 criteria.setAltitudeRequired(false);
26 criteria.setBearingRequired(false);
27 criteria.setCostAllowed(true);
28 criteria.setPowerRequirement(Criteria.POWER_LOW);
更多精彩
赞助商链接