layout
1 2 3 4 5 |
|
btn_measure.xml
1 2 3 4 5 6 7 | version="1.0" encoding="UTF-8"?> |
1 2 3 4 5 |
|
1 2 3 4 5 6 7 | xml version="1.0" encoding="UTF-8"?> |
1 2 3 4 5 6 7 8 9 10 11 12 13 | //隐藏 缩放控件和 百度logo private void hideZoomCtler() { if(mMapView==null) return ; int count = mMapView.getChildCount(); for (int i = 0; i < count; i++) { View child = mMapView.getChildAt(i); // 隐藏百度logo ZoomControl if (child instanceof ImageView || child instanceof ZoomControls) child.setVisibility(View.INVISIBLE); } }參考文章 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | /** * 强制帮用户打开GPS * * @param context */ public static final void openGPS(Context context) { Intent GPSIntent = new Intent(); GPSIntent.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider"); GPSIntent.addCategory("android.intent.category.ALTERNATIVE"); GPSIntent.setData(Uri.parse("custom:3")); try { PendingIntent.getBroadcast(context, 0, GPSIntent, 0).send(); } catch (CanceledException e) { e.printStackTrace(); } } /** * 判断GPS是否开启,GPS或者AGPS开启一个就认为是开启的 * * @param context * @return true 表示开启 */ public static final boolean isOPen(final Context context) { LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); // 通过GPS卫星定位,定位级别可以精确到街(通过24颗卫星定位,在室外和空旷的地方定位准确、速度快) boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); // 通过WLAN或移动网络(3G/2G)确定的位置(也称作AGPS,辅助GPS定位。主要用于在室内或遮盖物(建筑群或茂密的深林等)密集的地方定位) boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); if (gps || network) { return true; } return false; } |
1 2 3 4 5 6 | //BB叫 int alertId; SoundPool soundPool; soundPool = new SoundPool(10, AudioManager.STREAM_SYSTEM, 5); alertId = soundPool.load(this, R.raw.bb, 1); soundPool.play(alertId, 1.0f, 1.0f, 0, 0, 1.0f); |
1 2 3 4 5 6 | setVibrate(1000); // 震動 1 秒 public void setVibrate(long time){ Vibrator myVibrator = (Vibrator) getSystemService(Service.VIBRATOR_SERVICE); myVibrator.vibrate(time); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 | // 短震動20次 countdowntimer = new CountDownTimer(10500, 500) { @Override public void onTick(long millisUntilFinished) { // TODO Auto-generated method stub setVibrate(100); } @Override public void onFinish() { // TODO Auto-generated method stub } }.start(); |
1 2 3 4 5 6 7 8 9 10 11 12 13 | // 判斷否有SD卡 if(android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)){ output = new FileOutputStream("/sdcard/output.txt"); }else{ output = new FileOutputStream("/data/data/output.txt"); } String bt = "輸入訊息"; try { // 轉byte output.write(bt.getBytes()); } catch (IOException e) { e.printStackTrace(); } |
1
2
3
4
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
參考網站:
http://blog.csdn.net/xinzheng_wang/article/details/7827775