Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/235.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android GPSTracker不';登录google play后无法工作_Android_Gps_Location_Google Play_Google Play Services - Fatal编程技术网

Android GPSTracker不';登录google play后无法工作

Android GPSTracker不';登录google play后无法工作,android,gps,location,google-play,google-play-services,Android,Gps,Location,Google Play,Google Play Services,所以我花了整整一天的时间想知道为什么我的应用程序不工作,特别是GPSTracker,上个月运行得很好。但突然它停止了,在找不到出路后,我尝试在我的手机上重置出厂设置,它成功了。但在我登录我的Google play帐户后,它立即停止工作,有人知道这里发生了什么吗?是阻止了我的定位服务还是什么? 代码如下: public class GPSTracker extends Service implements LocationListener { private final Context con

所以我花了整整一天的时间想知道为什么我的应用程序不工作,特别是GPSTracker,上个月运行得很好。但突然它停止了,在找不到出路后,我尝试在我的手机上重置出厂设置,它成功了。但在我登录我的Google play帐户后,它立即停止工作,有人知道这里发生了什么吗?是阻止了我的定位服务还是什么? 代码如下:

public class GPSTracker extends Service implements LocationListener {


private final Context context;

boolean isGPSEnabled = false;
boolean isNetworkEnabled = false;
boolean canGetLocation = false;

Location location;

double latitude;
double longitude;

private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 5;
private static final long MIN_TIME_BW_UPDATES = 5000;
protected LocationManager locationManager;

public GPSTracker(Context context) {
    this.context = context;
    getLocation();
}

public Location getLocation() {
    try {
        locationManager = (LocationManager) context.getSystemService(LOCATION_SERVICE);

        isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

        isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

        if(!isGPSEnabled && !isNetworkEnabled) {

        } else {
            this.canGetLocation = true;

            if (isNetworkEnabled) {

                locationManager.requestLocationUpdates(
                        LocationManager.NETWORK_PROVIDER,
                        MIN_TIME_BW_UPDATES,
                        MIN_DISTANCE_CHANGE_FOR_UPDATES, this);

                if (locationManager != null) {
                    location = locationManager
                            .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

                    if (location != null) {

                        latitude = location.getLatitude();
                        longitude = location.getLongitude();
                    }
                }

            }

            if(isGPSEnabled) {
                if(location == null) {
                    locationManager.requestLocationUpdates(
                            LocationManager.GPS_PROVIDER,
                            MIN_TIME_BW_UPDATES,
                            MIN_DISTANCE_CHANGE_FOR_UPDATES, this);

                    if(locationManager != null) {
                        location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

                        if(location != null) {
                            latitude = location.getLatitude();
                            longitude = location.getLongitude();

                        }
                    }
                }
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

    return location;
}


public void stopUsingGPS() {
    if(locationManager != null) {
        locationManager.removeUpdates(GPSTracker.this);
    }
}

public double getLatitude() {
    if(location != null) {
        latitude = location.getLatitude();
    }
    return latitude;
}

public double getLongitude() {
    if(location != null) {
        longitude = location.getLongitude();
    }

    return longitude;
}

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

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

    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() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            context.startActivity(intent);
        }
    });

    alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    alertDialog.show();
}



@Override
public void onLocationChanged(Location location) {

    this.location = location;
    getLatitude();
    getLongitude();

    ParseUser user2 = ParseUser.getCurrentUser();
    ParseGeoPoint geoPoint = new ParseGeoPoint(getLatitude(), getLongitude());
    user2.put("lat_long", geoPoint);
    user2.saveInBackground();

    Log.d("Coordinates", getLatitude() + " " + getLongitude());

    String username = user2.getUsername();
    ParseQuery<ParseObject> query = ParseQuery.getQuery("_User");
    query.whereWithinKilometers("lat_long", geoPoint, 0.03);
    query.whereNotEqualTo("username", username);

    query.findInBackground(new FindCallback<ParseObject>() {
        public void done(List<ParseObject> listUsers, ParseException e) {

            for (ParseObject object : listUsers){

                String ids = object.getString("fullname");
                Log.d("These people are here:"," "+ids);

                SharedPreferences sharedPrefs = context.getSharedPreferences("com.parseapp.eseen.eseen", Context.MODE_PRIVATE);
                Boolean onOFF = sharedPrefs.getBoolean("ToggleOnOff", true);
                SharedPreferences settings = context.getSharedPreferences("NotificationIDs", Context.MODE_PRIVATE);
                SharedPreferences.Editor editor = settings.edit();
                Set<String> myStrings = settings.getStringSet("myStrings", new HashSet<String>());
                ParseInstallation installation = ParseInstallation.getCurrentInstallation();




                if (onOFF) {
                    int a = 0;
                    for (String checking : myStrings) {

                        if (object.getObjectId().equals(checking)) {
                            a = 1;
                        }
                    }
                    if (a == 1) {
                        Log.d("This user: ", object.getString("fullname")+"---Exists");

                    } else {

                        ParseUser user = ParseUser.getCurrentUser();
                        ParseQuery query = ParseInstallation.getQuery();
                        query.whereEqualTo("user", user.getObjectId());
                        installation.saveInBackground();



                        ParsePush androidPush = new ParsePush();
                        androidPush.setMessage(object.getString("fullname") + " is near you!");
                        androidPush.setQuery(query);
                        androidPush.sendInBackground();
                        myStrings.add(object.getObjectId());
                        editor.putStringSet("myStrings", myStrings);
                        editor.apply();
                    }

                }



            }

        }
    });







}




@Override
public void onProviderDisabled(String arg0) {
    // TODO Auto-generated method stub

}

@Override
public void onProviderEnabled(String arg0) {
    // TODO Auto-generated method stub

}

@Override
public void onStatusChanged(String arg0, int arg1, Bundle arg2) {
    // TODO Auto-generated method stub

}

@Override
public IBinder onBind(Intent intent) {
    // TODO Auto-generated method stub
    return null;
}
公共类GPSTracker扩展服务实现LocationListener{
私人最终语境;
布尔值isGPSEnabled=false;
布尔值isNetworkEnabled=false;
布尔值canGetLocation=false;
位置;
双纬度;
双经度;
私有静态最终长距离最小距离更改更新=5;
私有静态最终长最小时间更新=5000;
受保护的LocationManager LocationManager;
公共GPSTracker(上下文){
this.context=上下文;
getLocation();
}
公共位置getLocation(){
试一试{
locationManager=(locationManager)context.getSystemService(LOCATION\u服务);
isGPSEnabled=locationManager.isProviderEnabled(locationManager.GPS\U提供程序);
isNetworkEnabled=locationManager.isProviderEnabled(locationManager.NETWORK\u提供程序);
如果(!isGPSEnabled&!isNetworkEnabled){
}否则{
this.canGetLocation=true;
if(可联网){
locationManager.RequestLocationUpdate(
LocationManager.NETWORK\u提供程序,
最短时间更新,
最小距离\u更改\u用于更新,此);
如果(locationManager!=null){
位置=位置管理器
.getLastKnownLocation(LocationManager.网络提供商);
如果(位置!=null){
纬度=位置。getLatitude();
longitude=location.getLongitude();
}
}
}
如果(isGPSEnabled){
if(位置==null){
locationManager.RequestLocationUpdate(
LocationManager.GPS\u提供程序,
最短时间更新,
最小距离\u更改\u用于更新,此);
如果(locationManager!=null){
location=locationManager.getLastKnownLocation(locationManager.GPS\U提供程序);
如果(位置!=null){
纬度=位置。getLatitude();
longitude=location.getLongitude();
}
}
}
}
}
}捕获(例外e){
e、 printStackTrace();
}
返回位置;
}
使用GPS()的公共无效停止{
如果(locationManager!=null){
locationManager.RemoveUpdate(GPSTracker.this);
}
}
公共双纬度(){
如果(位置!=null){
纬度=位置。getLatitude();
}
返回纬度;
}
公共双getLongitude(){
如果(位置!=null){
longitude=location.getLongitude();
}
返回经度;
}
公共布尔canGetLocation(){
返回此.canGetLocation;
}
公共void showSettingsAlert(){
AlertDialog.Builder AlertDialog=新建AlertDialog.Builder(上下文);
alertDialog.setTitle(“GPS是设置”);
alertDialog.setMessage(“GPS未启用。是否转到设置菜单?”);
alertDialog.setPositiveButton(“设置”,新的DialogInterface.OnClickListener(){
@凌驾
public void onClick(DialogInterface dialog,int which){
意向意向=新意向(设置、动作、位置、来源、设置);
背景。开始触觉(意图);
}
});
alertDialog.setNegativeButton(“取消”,新建DialogInterface.OnClickListener(){
@凌驾
public void onClick(DialogInterface dialog,int which){
dialog.cancel();
}
});
alertDialog.show();
}
@凌驾
已更改位置上的公共无效(位置){
这个位置=位置;
getLatitude();
getLongitude();
ParseUser user2=ParseUser.getCurrentUser();
ParseGeoPoint geoPoint=新的ParseGeoPoint(getLatitude(),getLatitude());
用户2.put(“lat_long”,地质点);
user2.saveInBackground();
Log.d(“坐标”,getLatitude()+“”+getLatitude());
字符串username=user2.getUsername();
ParseQuery=ParseQuery.getQuery(“_User”);
查询。其中里程计(“拉图长”,地质点,0.03);
查询。whereNotEqualTo(“用户名”,用户名);
findInBackground(新的FindCallback(){
public void done(列表用户,parsee异常){
for(ParseObject对象:listUsers){
字符串ID=object.getString(“全名”);
Log.d(“这些人在这里:”、“+id”);
SharedReferences SharedReferences=context.getSharedReferences(“com.parseapp.eseen.eseen”,context.MODE_PRIVATE);
Boolean onOFF=sharedPrefs.getBoolean(“ToggleOnOff”,true);
SharedReferences设置=context.getSharedReferences(“notificationId”,context.MODE\u PRIVATE);
SharedReferences.Editor=settings.edit();
Set myStrings=settings.getStringSet(“myStrings”,new HashSet());
ParseInstallation=ParseInstallation.getCurrentInstallation();
if(onOFF){
int a=0;
for(字符串检查:myStrings){
if(object.getObjectId().equals(检查)){
a=1;
}
}
如果(a==1){
Log.d(“此用户:”,object.getString(“全名”)+“--Exists”);
}否则{
标准杆数