-2

我有一个正在运行的 GPS 服务,但我无法将我当前的位置与之前保存在数据库中的位置进行比较。该应用程序运行良好,但是当我取出用 onLocationChange() 编写的函数时,它会崩溃。

功能是:

LocationsDB db = new LocationsDB(this);
     Cursor c = db.getAllLocations();
     c.moveToFirst(); 

     while(c.moveToNext()) {             
        arlist.add(c.getString(c.getColumnIndex("FIELD_LNG")));
        arlistlat.add(c.getString(c.getColumnIndex("FIELD_LAT")));

        }

    for(int i=0;i<arlist.size();i++){
        if(arlist.get(i)==Double.toString(location.getLongitude()) && arlistlat.get(i)==Double.toString(location.getLatitude())){
            Intent myIntent=new Intent(GPSTracker.this,alarm.class);
            startActivity(myIntent);
        }
    }
4

1 回答 1

0

不要==用来比较String

而是使用.equal.match

像这样的东西:

if(arlist.get(i)==Double.toString(location.getLongitude()) && arlistlat.get(i).equal(Double.toString(location.getLatitude()))){
于 2013-07-26T09:03:10.527 回答