Pozdrav!
Krenuo sam raditi jedan program za android i zapeo sam kod For petlje budući sam nov u svemu ovome.
Imam 10 koordinata pa bi se trebao upaliti alarm kad se mobitel nađe u blizini tih koordinata. Testirao sam unoseći ručno koordinate i tako radi program, znači dobro računa udaljenost i upali alarm ali je problem kod petlje, nešto sam preskočio ili krivo napravio (vjerojatno je problem sa "i" u petlji) pa ako možete pomoći.
Ovo je dio koda.
Hvala!
editTextlatitude.setText(lat);
editText2longitude.setText(longitu);
Double lat1=45.131432;
Double longi1=14.785698;
Double lat2=45.169786;
Double longi2=14.703899;
Double lat3=45.3238795;
Double longi3=14.4907;
Double lat4=45.3355084;
Double longi4=14.4182;
Double lat5=45.3394678;
Double longi5=14.3941149;
Double lat6=45.3484922;
Double longi6=14.3777615;
Double lat7=45.3433005;
Double longi7=14.41249;
Double lat8=45.3181406;
Double longi8=14.4697;
Double lat9=45.3017371;
Double longi9=14.5029402;
Double lat10=45.3513762;
Double longi10=14.345140500000001;
int i;
for (i=1;i<=10;i++){
Location locationA = new Location("point A");
locationA.setLatitude(Double.parseDouble(lat));
locationA.setLongitude(Double.parseDouble(longitu));
Location locationB = new Location("point B");
locationB.setLatitude(lat(i));
locationB.setLongitude(longi(i));
double distance = locationA.distanceTo(locationB);
if(distance < 1500.00) {
MediaPlayer mediaPlayer = MediaPlayer.create(this, R.raw.alarm);
mediaPlayer.start();
editTextdist.setText(Float.toString((float) distance));
}else{
editTextinfo.setText("");
}