Compare commits
1 Commits
master
...
background
Author | SHA1 | Date | |
---|---|---|---|
49b914a0b1 |
@ -6,6 +6,8 @@
|
|||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.hardware.location"
|
android:name="android.hardware.location"
|
||||||
@ -27,7 +29,8 @@
|
|||||||
|
|
||||||
<receiver android:name=".utils.BroadcastLocalizationHandler"
|
<receiver android:name=".utils.BroadcastLocalizationHandler"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="false"
|
android:exported="true"
|
||||||
|
android:launchMode="singleTop"
|
||||||
>
|
>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="background.location.broadcast">
|
<action android:name="background.location.broadcast">
|
||||||
@ -35,8 +38,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<activity android:name=".activity.StartupActivity"
|
<activity android:name=".activity.StartupActivity"
|
||||||
android:label="@string/title_activity_startup"
|
android:label="@string/title_activity_startup"
|
||||||
android:launchMode="singleInstance">
|
android:launchMode="singleInstance">
|
||||||
@ -61,7 +62,11 @@
|
|||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".service.BackgroundLocalizationService"/>
|
android:name=".service.BackgroundLocalizationService"
|
||||||
|
android:launchMode="singleTop"
|
||||||
|
android:enabled="true"
|
||||||
|
android:exported="false"
|
||||||
|
/>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
|||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.observers.DisposableSingleObserver;
|
import io.reactivex.observers.DisposableSingleObserver;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
import static android.Manifest.permission.READ_CONTACTS;
|
import static android.Manifest.permission.READ_CONTACTS;
|
||||||
|
|
||||||
@ -367,7 +368,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(Throwable e) {
|
||||||
Log.e("LoginError", "onError: " + e.getMessage());
|
Timber.e("onError: %s", e.getMessage());
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
return true;
|
return true;
|
||||||
|
@ -5,6 +5,7 @@ import android.content.BroadcastReceiver;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Build;
|
||||||
import android.support.design.widget.BottomNavigationView;
|
import android.support.design.widget.BottomNavigationView;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
@ -12,27 +13,25 @@ import android.support.v4.content.LocalBroadcastManager;
|
|||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
|
|
||||||
|
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
|
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
import com.mapbox.mapboxsdk.Mapbox;
|
import com.mapbox.mapboxsdk.Mapbox;
|
||||||
import com.uam.wmi.findmytutor.R;
|
import com.uam.wmi.findmytutor.R;
|
||||||
import com.uam.wmi.findmytutor.utils.BroadcastLocalizationHandler;
|
import com.uam.wmi.findmytutor.utils.BroadcastLocalizationHandler;
|
||||||
|
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
|
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
private BottomNavigationView mMainNav;
|
private BottomNavigationView mMainNav;
|
||||||
@ -54,8 +53,8 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
Mapbox.getInstance(this, getString(R.string.access_token));
|
Mapbox.getInstance(this, getString(R.string.access_token));
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
mMainFrame = (FrameLayout) findViewById(R.id.main_frame);
|
mMainFrame = findViewById(R.id.main_frame);
|
||||||
mMainNav = (BottomNavigationView) findViewById(R.id.main_nav);
|
mMainNav = findViewById(R.id.main_nav);
|
||||||
isTutor = PrefUtils.getIsTutor(getApplicationContext());
|
isTutor = PrefUtils.getIsTutor(getApplicationContext());
|
||||||
|
|
||||||
if (!isTutor) {
|
if (!isTutor) {
|
||||||
@ -95,11 +94,12 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
final FloatingActionButton button = findViewById(R.id.logoutButton);
|
final FloatingActionButton button = findViewById(R.id.logoutButton);
|
||||||
button.setOnClickListener(view -> {
|
button.setOnClickListener(view -> {
|
||||||
PrefUtils.cleanUserLocalStorage(getApplicationContext());
|
PrefUtils.cleanUserLocalStorage(getApplicationContext());
|
||||||
unRegisterLocalizationService();
|
|
||||||
|
|
||||||
Intent i = getBaseContext().getPackageManager()
|
Intent i = getBaseContext().getPackageManager()
|
||||||
.getLaunchIntentForPackage(getBaseContext().getPackageName());
|
.getLaunchIntentForPackage(getBaseContext().getPackageName());
|
||||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
unRegisterLocalizationService();
|
||||||
finish();
|
finish();
|
||||||
startActivity(i);
|
startActivity(i);
|
||||||
|
|
||||||
@ -131,10 +131,15 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (isTutor) {
|
if (isTutor) {
|
||||||
|
|
||||||
Intent intent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
Intent intent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
|
||||||
startService(intent);
|
startService(intent);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
//startForegroundService(intent);
|
||||||
|
ContextCompat.startForegroundService(getApplicationContext(),intent);
|
||||||
|
} else {
|
||||||
|
startService(intent);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(getApplicationContext(), "Please enable the gps", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), "Please enable the gps", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
@ -142,7 +147,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
@ -187,7 +192,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
Intent intent = new Intent(this, BackgroundLocalizationService.class);
|
Intent intent = new Intent(this, BackgroundLocalizationService.class);
|
||||||
stopService(intent);
|
stopService(intent);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
Log.d("Destroy app", "RECIEVER UNREGISTER ERROR");
|
Timber.d("RECIEVER UNREGISTER ERROR");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,48 @@
|
|||||||
package com.uam.wmi.findmytutor.service;
|
package com.uam.wmi.findmytutor.service;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationChannel;
|
||||||
|
import android.app.NotificationManager;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.support.annotation.RequiresApi;
|
||||||
import android.support.v4.app.ActivityCompat;
|
import android.support.v4.app.ActivityCompat;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.uam.wmi.findmytutor.R;
|
||||||
|
import com.uam.wmi.findmytutor.model.Coordinate;
|
||||||
|
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||||
|
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
||||||
|
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
import io.reactivex.observers.DisposableSingleObserver;
|
||||||
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||||
|
|
||||||
public class BackgroundLocalizationService extends Service {
|
public class BackgroundLocalizationService extends Service {
|
||||||
|
|
||||||
public static String str_receiver = "background.location.broadcast";
|
public static String str_receiver = "background.location.broadcast";
|
||||||
private static final String TAG = "MyLocationService";
|
private static final String TAG = "background.location.broadcast";
|
||||||
private LocationManager mLocationManager = null;
|
private LocationManager mLocationManager = null;
|
||||||
private static final int LOCATION_INTERVAL = 10000;
|
private static final int LOCATION_INTERVAL = 10000;
|
||||||
private static final float LOCATION_DISTANCE = 10f;
|
private static final float LOCATION_DISTANCE = 10f;
|
||||||
@ -33,6 +54,8 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
Location location;
|
Location location;
|
||||||
|
|
||||||
double latitude, longitude;
|
double latitude, longitude;
|
||||||
|
// Constants
|
||||||
|
private static final int ID_SERVICE = 101;
|
||||||
|
|
||||||
|
|
||||||
boolean isGPSEnable = false;
|
boolean isGPSEnable = false;
|
||||||
@ -40,31 +63,31 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
|
|
||||||
private class LocationListener implements android.location.LocationListener {
|
private class LocationListener implements android.location.LocationListener {
|
||||||
|
|
||||||
public LocationListener(String provider) {
|
LocationListener(String provider) {
|
||||||
Log.e(TAG, "LocationListener " + provider);
|
Timber.e("LocationListener %s", provider);
|
||||||
mLastLocation = new Location(provider);
|
mLastLocation = new Location(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLocationChanged(Location location) {
|
public void onLocationChanged(Location location) {
|
||||||
Log.e(TAG, "onLocationChanged: " + location);
|
Timber.e("onLocationChanged: %s", location);
|
||||||
mLastLocation.set(location);
|
mLastLocation.set(location);
|
||||||
sendToBroadcast(mLastLocation);
|
sendToBroadcast(mLastLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProviderDisabled(String provider) {
|
public void onProviderDisabled(String provider) {
|
||||||
Log.e(TAG, "onProviderDisabled: " + provider);
|
Timber.e("onProviderDisabled: %s", provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProviderEnabled(String provider) {
|
public void onProviderEnabled(String provider) {
|
||||||
Log.e(TAG, "onProviderEnabled: " + provider);
|
Timber.e("onProviderEnabled: %s", provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
public void onStatusChanged(String provider, int status, Bundle extras) {
|
||||||
Log.e(TAG, "onStatusChanged: " + provider);
|
Timber.e("onStatusChanged: %s", provider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,23 +102,95 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void startJob() throws InterruptedException {
|
||||||
|
//do job here
|
||||||
|
|
||||||
|
//job completed. Rest for 5 second before doing another one
|
||||||
|
try {
|
||||||
|
Thread.sleep(5000);
|
||||||
|
Log.e("loc","job") ;
|
||||||
|
fn_getlocation();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//do job again
|
||||||
|
startJob();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("LongLogTag")
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
Log.e(TAG, "onStartCommand");
|
Log.e(TAG,"onStartCommand");
|
||||||
super.onStartCommand(intent, flags, startId);
|
super.onStartCommand(intent, flags, startId);
|
||||||
|
/*
|
||||||
|
|
||||||
|
Thread t = new Thread(() -> {
|
||||||
|
try {
|
||||||
|
startJob();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
t.start();
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
|
||||||
|
Notification.Builder builder = new Notification.Builder(this, "FOREGROUND_SERVICE")
|
||||||
|
.setContentTitle(getString(R.string.app_name))
|
||||||
|
.setContentText("background")
|
||||||
|
.setAutoCancel(true);
|
||||||
|
|
||||||
|
Notification notification = builder.build();
|
||||||
|
startForeground(101, notification);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
|
||||||
|
.setContentTitle(getString(R.string.app_name))
|
||||||
|
.setContentText("background")
|
||||||
|
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||||
|
.setAutoCancel(true);
|
||||||
|
|
||||||
|
Notification notification = builder.build();
|
||||||
|
|
||||||
|
startForeground(101, notification);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
return START_STICKY;
|
return START_STICKY;
|
||||||
}
|
}
|
||||||
|
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||||
|
private void startMyOwnForeground(){
|
||||||
|
|
||||||
|
String NOTIFICATION_CHANNEL_ID = "com.example.simpleapp";
|
||||||
|
String channelName = "My Background Service";
|
||||||
|
NotificationChannel chan = new NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_NONE);
|
||||||
|
chan.setLightColor(Color.BLUE);
|
||||||
|
chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
|
||||||
|
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
|
assert manager != null;
|
||||||
|
manager.createNotificationChannel(chan);
|
||||||
|
|
||||||
|
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID);
|
||||||
|
Notification notification = notificationBuilder.setOngoing(true)
|
||||||
|
.setContentTitle("App is running in background")
|
||||||
|
.setPriority(NotificationManager.IMPORTANCE_MIN)
|
||||||
|
.setCategory(Notification.CATEGORY_SERVICE)
|
||||||
|
.build();
|
||||||
|
startForeground(2, notification);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
|
|
||||||
Log.e(TAG, "onCreate");
|
Timber.e("onCreate");
|
||||||
|
|
||||||
Notification notification = new NotificationCompat.Builder(this, "NOTIFICATION_CHANNEL")
|
|
||||||
.setContentText("Content").build();
|
|
||||||
|
|
||||||
startForeground(1001, notification);
|
|
||||||
|
|
||||||
initializeLocationManager();
|
initializeLocationManager();
|
||||||
|
|
||||||
@ -107,9 +202,9 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
mLocationListeners[0]
|
mLocationListeners[0]
|
||||||
);
|
);
|
||||||
} catch (java.lang.SecurityException ex) {
|
} catch (java.lang.SecurityException ex) {
|
||||||
Log.i(TAG, "fail to request location update, ignore", ex);
|
Timber.i(ex, "fail to request location update, ignore");
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
Log.d(TAG, "network provider does not exist, " + ex.getMessage());
|
Timber.d("network provider does not exist, %s", ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -120,29 +215,36 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
mLocationListeners[1]
|
mLocationListeners[1]
|
||||||
);
|
);
|
||||||
} catch (java.lang.SecurityException ex) {
|
} catch (java.lang.SecurityException ex) {
|
||||||
Log.i(TAG, "fail to request location update, ignore", ex);
|
Timber.i(ex, "fail to request location update, ignore");
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
Log.d(TAG, "gps provider does not exist " + ex.getMessage());
|
Timber.d("gps provider does not exist %s", ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer mTimer = new Timer();
|
Timer mTimer = new Timer();
|
||||||
mTimer.schedule(new TimerTaskToGetLocation(), 5, notify_interval);
|
mTimer.schedule(new TimerTaskToGetLocation(), 5, notify_interval);
|
||||||
intent = new Intent(str_receiver);
|
intent = new Intent(str_receiver);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O)
|
||||||
|
startMyOwnForeground();
|
||||||
|
else
|
||||||
|
startForeground(1, new Notification());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void fn_getlocation() {
|
private void fn_getlocation() {
|
||||||
|
try {
|
||||||
locationManager = (LocationManager) getApplicationContext().getSystemService(LOCATION_SERVICE);
|
locationManager = (LocationManager) getApplicationContext().getSystemService(LOCATION_SERVICE);
|
||||||
isGPSEnable = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
|
isGPSEnable = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
|
||||||
isNetworkEnable = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
|
isNetworkEnable = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
|
||||||
|
|
||||||
if (!isGPSEnable && !isNetworkEnable) {
|
} catch (Exception e) {
|
||||||
|
Timber.d("isProviderEnabled does not exist %s", e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isGPSEnable && isNetworkEnable) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
Log.e("loc","dzialam") ;
|
||||||
if (isGPSEnable) {
|
if (isGPSEnable) {
|
||||||
location = null;
|
location = null;
|
||||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||||
@ -156,13 +258,13 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, mLocationListeners[1]);
|
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, mLocationListeners[1]);
|
||||||
if (locationManager!=null){
|
if (locationManager != null) {
|
||||||
location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||||
if (location!=null){
|
if (location != null) {
|
||||||
latitude = location.getLatitude();
|
latitude = location.getLatitude();
|
||||||
longitude = location.getLongitude();
|
longitude = location.getLongitude();
|
||||||
|
|
||||||
fn_update(location);
|
sendToBroadcast(location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,10 +296,10 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
|
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
|
||||||
if (location!=null){
|
if (location != null) {
|
||||||
latitude = location.getLatitude();
|
latitude = location.getLatitude();
|
||||||
longitude = location.getLongitude();
|
longitude = location.getLongitude();
|
||||||
fn_update(location);
|
sendToBroadcast(location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,25 +310,28 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TimerTaskToGetLocation extends TimerTask{
|
private class TimerTaskToGetLocation extends TimerTask {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mHandler.post(BackgroundLocalizationService.this::fn_getlocation);
|
mHandler.post(BackgroundLocalizationService.this::fn_getlocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
private void fn_update(Location location){
|
private void fn_update(Location location) {
|
||||||
intent.putExtra("latitude",location.getLatitude());
|
intent.putExtra("latitude", location.getLatitude());
|
||||||
intent.putExtra("longitude",location.getLongitude());
|
intent.putExtra("longitude", location.getLongitude());
|
||||||
sendBroadcast(intent);
|
sendToBroadcast(Location location);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
private void sendToBroadcast(Location location) {
|
private void sendToBroadcast(Location location) {
|
||||||
Log.e("sendToBroadcast", String.valueOf(location));
|
Timber.e(String.valueOf(location));
|
||||||
|
Log.e("err", String.valueOf(location));
|
||||||
|
|
||||||
intent.putExtra("latitude",location.getLatitude());
|
intent.putExtra("latitude", location.getLatitude());
|
||||||
intent.putExtra("longitude",location.getLongitude());
|
intent.putExtra("longitude", location.getLongitude());
|
||||||
sendBroadcast(intent);
|
new Task(location).execute();
|
||||||
|
|
||||||
|
// sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getLocation() {
|
private void getLocation() {
|
||||||
@ -235,27 +340,80 @@ public class BackgroundLocalizationService extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
Log.e(TAG, "onDestroy");
|
Timber.e("onDestroy");
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
|
||||||
if (mLocationManager != null) {
|
if (mLocationManager != null) {
|
||||||
for (int i = 0; i < mLocationListeners.length; i++) {
|
for (LocationListener mLocationListener : mLocationListeners) {
|
||||||
try {
|
try {
|
||||||
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mLocationManager.removeUpdates(mLocationListeners[i]);
|
mLocationManager.removeUpdates(mLocationListener);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.i(TAG, "fail to remove location listener, ignore", ex);
|
Timber.i(ex, "fail to remove location listener, ignore");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeLocationManager() {
|
private void initializeLocationManager() {
|
||||||
Log.e(TAG, "initializeLocationManager - LOCATION_INTERVAL: " + LOCATION_INTERVAL + " LOCATION_DISTANCE: " + LOCATION_DISTANCE);
|
Timber.e("initializeLocationManager - LOCATION_INTERVAL: " + LOCATION_INTERVAL + " LOCATION_DISTANCE: " + LOCATION_DISTANCE);
|
||||||
|
|
||||||
if (mLocationManager == null) {
|
if (mLocationManager == null) {
|
||||||
mLocationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
|
mLocationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class Task extends AsyncTask {
|
||||||
|
private Double latitude;
|
||||||
|
private Double longitude;
|
||||||
|
|
||||||
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
private CoordinateService coordinateService = ApiClient.getClient(getApplicationContext())
|
||||||
|
.create(CoordinateService.class);
|
||||||
|
|
||||||
|
private Task(Location location) {
|
||||||
|
this.latitude = location.getLatitude();
|
||||||
|
this.longitude = location.getLongitude();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Object doInBackground(Object[] objects) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
Coordinate coordinate = new Coordinate(
|
||||||
|
this.latitude,
|
||||||
|
this.longitude,
|
||||||
|
PrefUtils.getUserStatus(getApplicationContext()),
|
||||||
|
PrefUtils.getUserId(getApplicationContext())
|
||||||
|
);
|
||||||
|
|
||||||
|
disposable.add(
|
||||||
|
coordinateService
|
||||||
|
.postCoordinate(coordinate)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribeWith(new DisposableSingleObserver<Coordinate>() {
|
||||||
|
@SuppressLint("LongLogTag")
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Coordinate coord) {
|
||||||
|
Log.e("CoordinateService onSuccess", String.valueOf(coord));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(Throwable e) {
|
||||||
|
Log.e("LoginError", "onError: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Timber.e(String.valueOf(e));
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,229 +0,0 @@
|
|||||||
package com.uam.wmi.findmytutor.service;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.app.Notification;
|
|
||||||
import android.app.Service;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.location.Location;
|
|
||||||
import android.location.LocationListener;
|
|
||||||
import android.location.LocationManager;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.IBinder;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.v4.app.ActivityCompat;
|
|
||||||
import android.support.v4.app.NotificationCompat;
|
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
|
|
||||||
import com.uam.wmi.findmytutor.utils.PrefUtils;
|
|
||||||
|
|
||||||
import java.util.Timer;
|
|
||||||
import java.util.TimerTask;
|
|
||||||
|
|
||||||
public class GoogleService extends Service {
|
|
||||||
|
|
||||||
|
|
||||||
boolean isGPSEnable = false;
|
|
||||||
boolean isNetworkEnable = false;
|
|
||||||
double latitude, longitude;
|
|
||||||
LocationManager locationManager;
|
|
||||||
Location location;
|
|
||||||
private Handler mHandler = new Handler();
|
|
||||||
private Timer mTimer = null;
|
|
||||||
long notify_interval = 50000;
|
|
||||||
public static String str_receiver = "background.location.broadcast";
|
|
||||||
Intent intent;
|
|
||||||
Location mLastLocation;
|
|
||||||
private static final String TAG = "MyLocationService";
|
|
||||||
private LocationManager mLocationManager = null;
|
|
||||||
|
|
||||||
public GoogleService() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public IBinder onBind(Intent intent) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate() {
|
|
||||||
super.onCreate();
|
|
||||||
|
|
||||||
mTimer = new Timer();
|
|
||||||
mTimer.schedule(new TimerTaskToGetLocation(), 5, notify_interval);
|
|
||||||
intent = new Intent(str_receiver);
|
|
||||||
|
|
||||||
Notification notification = new NotificationCompat.Builder(this, "NOTIFICATION_CHANNEL")
|
|
||||||
.setContentText("Content").build();
|
|
||||||
|
|
||||||
startForeground(1001, notification);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
||||||
Log.e(TAG, "onStartCommand");
|
|
||||||
super.onStartCommand(intent, flags, startId);
|
|
||||||
|
|
||||||
return START_STICKY;
|
|
||||||
}
|
|
||||||
|
|
||||||
private class LocationListener implements android.location.LocationListener {
|
|
||||||
|
|
||||||
public LocationListener(String provider) {
|
|
||||||
Log.e(TAG, "LocationListener " + provider);
|
|
||||||
mLastLocation = new Location(provider);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLocationChanged(Location location) {
|
|
||||||
Log.e(TAG, "onLocationChanged: " + location);
|
|
||||||
mLastLocation.set(location);
|
|
||||||
sendToBroadcast(mLastLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderDisabled(String provider) {
|
|
||||||
Log.e(TAG, "onProviderDisabled: " + provider);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProviderEnabled(String provider) {
|
|
||||||
Log.e(TAG, "onProviderEnabled: " + provider);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStatusChanged(String provider, int status, Bundle extras) {
|
|
||||||
Log.e(TAG, "onStatusChanged: " + provider);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LocationListener[] mLocationListeners = new LocationListener[]{
|
|
||||||
new LocationListener(LocationManager.GPS_PROVIDER),
|
|
||||||
new LocationListener(LocationManager.NETWORK_PROVIDER),
|
|
||||||
new LocationListener(LocationManager.PASSIVE_PROVIDER)
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
private void fn_getlocation() {
|
|
||||||
locationManager = (LocationManager) getApplicationContext().getSystemService(LOCATION_SERVICE);
|
|
||||||
isGPSEnable = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
|
|
||||||
isNetworkEnable = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
|
|
||||||
|
|
||||||
if (!isGPSEnable && !isNetworkEnable) {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
|
|
||||||
if (isGPSEnable) {
|
|
||||||
location = null;
|
|
||||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
// TODO: Consider calling
|
|
||||||
// ActivityCompat#requestPermissions
|
|
||||||
// here to request the missing permissions, and then overriding
|
|
||||||
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
|
|
||||||
// int[] grantResults)
|
|
||||||
// to handle the case where the user grants the permission. See the documentation
|
|
||||||
// for ActivityCompat#requestPermissions for more details.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, mLocationListeners[1]);
|
|
||||||
if (locationManager!=null){
|
|
||||||
location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
|
||||||
if (location!=null){
|
|
||||||
latitude = location.getLatitude();
|
|
||||||
longitude = location.getLongitude();
|
|
||||||
|
|
||||||
fn_update(location);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isNetworkEnable) {
|
|
||||||
location = null;
|
|
||||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
// TODO: Consider calling
|
|
||||||
// ActivityCompat#requestPermissions
|
|
||||||
// here to request the missing permissions, and then overriding
|
|
||||||
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
|
|
||||||
// int[] grantResults)
|
|
||||||
// to handle the case where the user grants the permission. See the documentation
|
|
||||||
// for ActivityCompat#requestPermissions for more details.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 0, mLocationListeners[0]);
|
|
||||||
|
|
||||||
if (locationManager != null) {
|
|
||||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
// TODO: Consider calling
|
|
||||||
// ActivityCompat#requestPermissions
|
|
||||||
// here to request the missing permissions, and then overriding
|
|
||||||
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
|
|
||||||
// int[] grantResults)
|
|
||||||
// to handle the case where the user grants the permission. See the documentation
|
|
||||||
// for ActivityCompat#requestPermissions for more details.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
|
|
||||||
if (location!=null){
|
|
||||||
latitude = location.getLatitude();
|
|
||||||
longitude = location.getLongitude();
|
|
||||||
fn_update(location);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TimerTaskToGetLocation extends TimerTask{
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
mHandler.post(GoogleService.this::fn_getlocation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void fn_update(Location location){
|
|
||||||
intent.putExtra("latitude",location.getLatitude());
|
|
||||||
intent.putExtra("longitude",location.getLongitude());
|
|
||||||
sendBroadcast(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendToBroadcast(Location location) {
|
|
||||||
Log.e("sendToBroadcast", String.valueOf(location));
|
|
||||||
|
|
||||||
intent.putExtra("latitude",location.getLatitude());
|
|
||||||
intent.putExtra("longitude",location.getLongitude());
|
|
||||||
sendBroadcast(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getLocation() {
|
|
||||||
sendToBroadcast(mLastLocation);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
Log.e(TAG, "onDestroy");
|
|
||||||
super.onDestroy();
|
|
||||||
if (mLocationManager != null) {
|
|
||||||
for (int i = 0; i < mLocationListeners.length; i++) {
|
|
||||||
try {
|
|
||||||
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mLocationManager.removeUpdates(mLocationListeners[i]);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Log.i(TAG, "fail to remove location listener, ignore", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,39 +4,21 @@ import android.annotation.SuppressLint;
|
|||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.os.Build;
|
||||||
import android.util.ArrayMap;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.auth0.android.jwt.Claim;
|
|
||||||
import com.auth0.android.jwt.JWT;
|
|
||||||
import com.uam.wmi.findmytutor.model.Coordinate;
|
import com.uam.wmi.findmytutor.model.Coordinate;
|
||||||
import com.uam.wmi.findmytutor.model.JwtToken;
|
|
||||||
import com.uam.wmi.findmytutor.model.LdapUser;
|
|
||||||
import com.uam.wmi.findmytutor.network.ApiClient;
|
import com.uam.wmi.findmytutor.network.ApiClient;
|
||||||
import com.uam.wmi.findmytutor.service.CoordinateService;
|
import com.uam.wmi.findmytutor.service.CoordinateService;
|
||||||
import com.uam.wmi.findmytutor.service.LdapService;
|
|
||||||
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.reactivestreams.Subscriber;
|
|
||||||
import org.reactivestreams.Subscription;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
import io.reactivex.observers.DisposableObserver;
|
|
||||||
import io.reactivex.observers.DisposableSingleObserver;
|
import io.reactivex.observers.DisposableSingleObserver;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
import okhttp3.RequestBody;
|
|
||||||
import okhttp3.ResponseBody;
|
|
||||||
import retrofit2.Call;
|
|
||||||
import retrofit2.Callback;
|
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
import static android.content.ContentValues.TAG;
|
|
||||||
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
|
||||||
|
|
||||||
public class BroadcastLocalizationHandler extends BroadcastReceiver {
|
public class BroadcastLocalizationHandler extends BroadcastReceiver {
|
||||||
@ -46,6 +28,8 @@ public class BroadcastLocalizationHandler extends BroadcastReceiver {
|
|||||||
final PendingResult pendingResult = goAsync();
|
final PendingResult pendingResult = goAsync();
|
||||||
Task asyncTask = new Task(pendingResult, intent);
|
Task asyncTask = new Task(pendingResult, intent);
|
||||||
asyncTask.execute();
|
asyncTask.execute();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Task extends AsyncTask {
|
private static class Task extends AsyncTask {
|
||||||
|
Loading…
Reference in New Issue
Block a user