2017-07-23 16 views
0

這個函數是什麼意思? 請簡化它,因爲我們是新開發位置服務類showSettingsAlert()函數含義

public void showSettingsAlert(){ 
     AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext); 

     // Setting Dialog Title 
     alertDialog.setTitle("GPS is settings"); 

     // Setting Dialog Message 
     alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?"); 

     // Setting Icon to Dialog 
     //alertDialog.setIcon(R.drawable.delete); 

     // On pressing Settings button 
     alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialog,int which) { 
       Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); 
       mContext.startActivity(intent); 
      } 
     }); 

回答

0

這一切是一個警報讓用戶知道未啓用定位服務。肯定響應按鈕(確定/是)打開位置設置頁面上的設置應用程序。

此功能不檢查位置服務是否啓用,它只顯示警報。你需要從確認這個的東西中調用這個函數。