-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 に答える