blob: 9d7b685f1bca6b7f144cece3dc8e64cf28f2bce1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package com.mapswithme.maps.location;
import android.content.Intent;
import android.content.IntentFilter;
import android.location.LocationManager;
import android.support.annotation.NonNull;
import com.mapswithme.maps.MwmApplication;
import com.mapswithme.maps.background.AppBackgroundTracker;
class TransitionListener implements AppBackgroundTracker.OnTransitionListener
{
@NonNull
private final GPSCheck mReceiver = new GPSCheck();
private boolean mReceiverRegistered;
@Override
public void onTransit(boolean foreground)
{
if (foreground && !mReceiverRegistered)
{
final IntentFilter filter = new IntentFilter();
filter.addAction(LocationManager.PROVIDERS_CHANGED_ACTION);
filter.addCategory(Intent.CATEGORY_DEFAULT);
MwmApplication.get().registerReceiver(mReceiver, filter);
mReceiverRegistered = true;
return;
}
if (!foreground && mReceiverRegistered)
{
MwmApplication.get().unregisterReceiver(mReceiver);
mReceiverRegistered = false;
}
}
}
|