Method sendLocationToTelegram is now responsible for checking if internet is available.

This commit is contained in:
Filip Strajnar 2024-10-27 13:25:18 +01:00
parent 32a4467bce
commit 44a01332ae

View file

@ -170,17 +170,17 @@ public class LocationLoggingService extends Service implements LocationListener
return; return;
} }
lastLocation = newLocation;
sendLocationToTelegram(lastLocation);
}
public void sendLocationToTelegram(Location location) {
if(!internetAvailable) if(!internetAvailable)
{ {
Log.i(TAG, "Internet is not available."); Log.i(TAG, "Internet is not available.");
return; return;
} }
lastLocation = newLocation;
sendLocationToTelegram(lastLocation);
}
public void sendLocationToTelegram(Location location){
String botToken = getResources().getString(R.string.telegramToken); String botToken = getResources().getString(R.string.telegramToken);
String telegramChat = getResources().getString(R.string.telegramChat); String telegramChat = getResources().getString(R.string.telegramChat);
TelegramBot bot = new TelegramBot(botToken); TelegramBot bot = new TelegramBot(botToken);