2016-11-11 4 views
-1

GPS位置を要求してから位置(緯度、経度)を求めるプロンプトをユーザに出したい。このようボタンがクリックされたときにGPS位置を要求する

は: http://4.bp.blogspot.com/-CC8P9RN7_pk/VPTwYyjt8kI/AAAAAAAABWw/A5cjqZc39hQ/s1600/Location%2BSettings%2BDialog.png

+0

ここにGoogleマップAPI(https://developers.google.com/maps/documentation/android-api/signup)を取得し、現在の場所を取得するために使用します。 – HaroldSer

+0

あなたは質問に関係していません。 –

答えて

0

GPSのためのコードはイネーブルプロンプト:

public boolean canGetLocation() { 
     return this.canGetLocation; 
    } 

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

     alertDialog.setTitle("GPS is settings"); 

     alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?"); 
     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); 
      } 
     }); 
     alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { 
      public void onClick(DialogInterface dialog, int which) { 
      dialog.cancel(); 
      } 
     }); 
     alertDialog.show(); 
    } 

あなたは現在の場所のために何をしたいです(緯度と同じように、長いですかグーグルマップ)。

関連する問題