mirror of
https://github.com/MatomoCamp/matomocamp-companion-android.git
synced 2024-09-19 16:13:46 +02:00
Removed restriction to only use Google Maps for directions if installed, allowing to use third-party apps or a browser.
This commit is contained in:
parent
74f1a7e2b3
commit
6f48640a13
1 changed files with 9 additions and 22 deletions
|
@ -1,11 +1,6 @@
|
|||
package be.digitalia.fosdem.fragments;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
@ -15,6 +10,9 @@ import android.view.MenuInflater;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import be.digitalia.fosdem.R;
|
||||
|
||||
public class MapFragment extends Fragment {
|
||||
|
@ -22,7 +20,6 @@ public class MapFragment extends Fragment {
|
|||
private static final double DESTINATION_LATITUDE = 50.812375;
|
||||
private static final double DESTINATION_LONGITUDE = 4.380734;
|
||||
private static final String DESTINATION_NAME = "ULB";
|
||||
private static final String GOOGLE_MAPS_PACKAGE_NAME = "com.google.android.apps.maps";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -52,22 +49,12 @@ public class MapFragment extends Fragment {
|
|||
|
||||
private void launchDirections() {
|
||||
// Build intent to start Google Maps directions
|
||||
String uri = String.format(Locale.US, "http://maps.google.com/maps?f=d&daddr=%1$f,%2$f(%3$s)&dirflg=r", DESTINATION_LATITUDE, DESTINATION_LONGITUDE,
|
||||
DESTINATION_NAME);
|
||||
String uri = String.format(Locale.US,
|
||||
"http://maps.google.com/maps?f=d&daddr=%1$f,%2$f(%3$s)&dirflg=r",
|
||||
DESTINATION_LATITUDE, DESTINATION_LONGITUDE, DESTINATION_NAME);
|
||||
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
|
||||
|
||||
// If Google Maps app is found, don't allow to choose other apps to handle this intent
|
||||
List<ResolveInfo> resolveInfos = getActivity().getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
|
||||
if (resolveInfos != null) {
|
||||
for (ResolveInfo info : resolveInfos) {
|
||||
if (GOOGLE_MAPS_PACKAGE_NAME.equals(info.activityInfo.packageName)) {
|
||||
intent.setPackage(GOOGLE_MAPS_PACKAGE_NAME);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue