Latitude and Longitude showing as 0 in Android

后端 未结 2 729
一向
一向 2021-01-14 18:39
  ************* TrackGPS.java *****************************  

    import android.app.AlertDialog;
    import android.app.Service;
    import android.content.Context         


        
2条回答
  •  情话喂你
    2021-01-14 19:42

    Please manage required permission for marshmallow.

    First you add this permission in manifest file

     
     
    

    After in your activity First declare two variable like this,

     private static final int REQUEST_CODE_PERMISSION = 1;
     String mPermission = Manifest.permission.ACCESS_FINE_LOCATION;
    

    After in onCreate method

     if(Build.VERSION.SDK_INT>= 23) {
    
            if (checkSelfPermission(mPermission) != PackageManager.PERMISSION_GRANTED) {
                ActivityCompat.requestPermissions(MainActivity.this,
                        new String[]{mPermission,
                        },
                        REQUEST_CODE_PERMISSION);
                return;
            }
    
            else
            {
                *here manage your code if permission already access
            }
        }
    

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题