google.navigation intent
This commit is contained in:
parent
b891142271
commit
4466cf4214
3 changed files with 44 additions and 5 deletions
|
@ -3,7 +3,7 @@
|
|||
package="net.osmand.plus" android:installLocation="auto" android:versionName="@string/app_version" android:versionCode="170">
|
||||
<meta-data android:name="com.google.android.backup.api_key"
|
||||
android:value="AEdPqrEAAAAIqF3tNGT66etVBn_vgzpfAY1wmIzKV1Ss6Ku-2A" />
|
||||
|
||||
|
||||
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="19"/>
|
||||
|
||||
<uses-feature android:name="android.hardware.camera" android:required="false" />
|
||||
|
@ -68,6 +68,7 @@
|
|||
<category android:name="android.intent.category.CAR_DOCK" />
|
||||
<category android:name="android.intent.category.DESK_DOCK" />
|
||||
</intent-filter>
|
||||
|
||||
<!-- android matches non-greedy : http://stackoverflow.com/questions/3400072/pathpattern-to-match-file-extension-does-not-work-if-a-period-exists-elsewhere-i-->
|
||||
<!-- mimeType&host are both needed or you will either have unwanted matching or no match when needed -->
|
||||
<intent-filter>
|
||||
|
@ -78,7 +79,16 @@
|
|||
<data android:scheme="file" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\..*\\..*\\.gpx"/>
|
||||
<data android:scheme="file" android:host="*" android:mimeType="*/*" android:pathPattern=".*\\..*\\..*\\..*\\.gpx"/>
|
||||
</intent-filter>
|
||||
<receiver android:name="net.osmand.plus.audionotes.MediaRemoteControlReceiver">
|
||||
|
||||
<!-- google navigation intent -->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:scheme="google.navigation"/>
|
||||
</intent-filter>
|
||||
|
||||
<receiver android:name="net.osmand.plus.audionotes.MediaRemoteControlReceiver">
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.CAMERA_BUTTON" />
|
||||
<action android:name="android.intent.action.MEDIA_BUTTON" />
|
||||
|
@ -141,13 +151,13 @@
|
|||
<activity android:name="net.osmand.plus.development.TestVoiceActivity"></activity>
|
||||
<activity android:name="net.osmand.plus.activities.LocalIndexesActivity" android:label="@string/local_index_descr_title"></activity>
|
||||
<activity android:name="net.osmand.plus.osmedit.LocalOpenstreetmapActivity" android:label="@string/local_openstreetmap_act_title"></activity>
|
||||
|
||||
|
||||
<service android:process="net.osmand.plus" android:label="@string/process_navigation_service" android:name="net.osmand.plus.NavigationService">
|
||||
<intent-filter><action android:name="net.osmand.plus.NavigationService"></action></intent-filter>
|
||||
</service>
|
||||
<receiver android:name="net.osmand.plus.OnNavigationServiceAlarmReceiver"/>
|
||||
<activity android:name="net.osmand.plus.activities.OsmandBidForFixActivity"></activity>
|
||||
|
||||
|
||||
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
@ -1733,4 +1733,5 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
|
|||
<string name="av_camera_focus_continuous">The camera continuously tries to focus</string>
|
||||
<string name="av_photo_play_sound">Play sound on photo shot</string>
|
||||
<string name="av_photo_play_sound_descr">Choose whether to play a sound when shooting photos</string>
|
||||
<string name="navigation_intent_invalid">Invalid format : %s</string>
|
||||
</resources>
|
||||
|
|
|
@ -6,6 +6,8 @@ import java.util.ArrayList;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.StateChangedListener;
|
||||
|
@ -335,10 +337,36 @@ public class MapActivity extends AccessibleActivity {
|
|||
if (intent.getData() != null)
|
||||
{
|
||||
final Uri data = intent.getData();
|
||||
if ("file".equalsIgnoreCase(data.getScheme()))
|
||||
final String scheme = data.getScheme();
|
||||
if ("file".equals(scheme))
|
||||
{
|
||||
showImportedGpx(data.getPath());
|
||||
}
|
||||
else if("google.navigation".equals(scheme))
|
||||
{
|
||||
final String schemeSpecificPart = data.getSchemeSpecificPart();
|
||||
|
||||
final Matcher matcher = Pattern.compile("q=(.+?),(.+?)").matcher(schemeSpecificPart);
|
||||
if (matcher.matches())
|
||||
{
|
||||
try
|
||||
{
|
||||
final double lat = Double.valueOf(matcher.group(1));
|
||||
final double lon = Double.valueOf(matcher.group(2));
|
||||
|
||||
getMyApplication().getTargetPointsHelper().navigateToPoint(new LatLon(lat, lon), false, -1);
|
||||
getMapActions().enterRoutePlanningMode(null, null);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
AccessibleToast.makeText(this, getString(R.string.navigation_intent_invalid, schemeSpecificPart), Toast.LENGTH_LONG).show(); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AccessibleToast.makeText(this, getString(R.string.navigation_intent_invalid, schemeSpecificPart), Toast.LENGTH_LONG).show(); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue