Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6662,18 +6662,25 @@ public void printStackTraceToStream(Throwable t, Writer o) {
* @return LocationControl Object
*/
public LocationManager getLocationManager() {
boolean permissionGranted = false;
if (Build.VERSION.SDK_INT >= 29 && "true".equals(Display.getInstance().getProperty("android.requiresBackgroundLocationPermissionForAPI29", "false"))) {

if (checkForPermission("android.permission.ACCESS_BACKGROUND_LOCATION", "This is required to get the location")) {
permissionGranted = true;
}

}
if (!permissionGranted && !checkForPermission( Manifest.permission.ACCESS_FINE_LOCATION, "This is required to get the location")) {
String permissionMessage = "This is required to get the location";
if (
!checkForPermission( Manifest.permission.ACCESS_FINE_LOCATION, permissionMessage)
) {
return null;
}

if (
Build.VERSION.SDK_INT >= 29
&& "true".equals(Display.getInstance().getProperty("android.requiresBackgroundLocationPermissionForAPI29", "false"))
) {
if (
!checkForPermission(
"android.permission.ACCESS_BACKGROUND_LOCATION",
permissionMessage
)
) {
com.codename1.io.Log.e(new RuntimeException("Background location permission denied"));
}
}

boolean includesPlayServices = Display.getInstance().getProperty("IncludeGPlayServices", "false").equals("true");
if (includesPlayServices && hasAndroidMarket()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class AndroidLocationPlayServiceManager extends com.codename1.location.Lo
LifecycleListener {



private static final int FLAG_MUTABLE = 33554432;
static class ParcelableUtil {
public static byte[] marshall(Parcelable parceable) {
Parcel parcel = Parcel.obtain();
Expand Down Expand Up @@ -477,12 +477,12 @@ private PendingIntent createGeofencePendingIntent(
}
Intent intent = new Intent(context, BackgroundLocationBroadcastReceiver.class);
intent.setAction(BackgroundLocationBroadcastReceiver.ACTION_PROCESS_GEOFENCE_TRANSITIONS);
intent.setData(Uri.parse("http://codenameone.com/a?" + geofenceListenerClass.getName()));
intent.putExtra("geofenceListenerClass", geofenceListenerClass.getName());
geofencePendingIntent = PendingIntent.getBroadcast(
AndroidNativeUtil.getContext().getApplicationContext(),
0,
intent,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE
PendingIntent.FLAG_UPDATE_CURRENT | FLAG_MUTABLE
);
return geofencePendingIntent;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ public void onReceive(Context context, Intent intent) {

String dataString = intent.getDataString();
if (dataString == null) {
return;
if (intent.getExtras() != null && intent.getExtras().get("geofenceListenerClass") != null) {
dataString = "-?" + intent.getExtras().get("geofenceListenerClass");
} else {
return;
}
}
String[] params = dataString.split("[?]");
if (params.length < 2) {
Expand Down
Loading