Android開啟系統設定

weixin_33711641發表於2013-06-27

 

今天在做專案過程中,遇到一個問題:使用者體驗某個功能時需要檢視使用者是否已經開啟了GPS定位服務,若沒有則要求進入定位服務設定介面。

 


下面就直接貼出程式碼


以下程式碼是放在了Button的監聽事件裡,只貼出重要的程式碼


 

 LocationManager alm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);  
	if (alm.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) {  
		Toast.makeText(getApplicationContext(), "GPS已經開啟", Toast.LENGTH_SHORT)   .show();  
		return;  
	}  
startActivity(new Intent("android.settings.LOCATION_SOURCE_SETTINGS"));


經過在網上查詢,還有許多開啟其他系統設定的情況,下面這篇文章中有相關介紹。


http://blog.csdn.net/get123/article/details/7698387


 


 

相關文章