preserve google maps settings screen until user takes action - android

I press a button and a dialog appears where the user selects if he wants to navigate to saved position.
Inside dialog:
String query = "SELECT latitude,longitude FROM MEMS ";
Cursor c1 = sqlHandler.selectQuery(query);
if (c1 != null && c1.getCount() != 0) {
if (c1.moveToFirst()) {
do {
String mylatitude=c1.getString(c1.getColumnIndex("latitude"));
String mylongitude=c1.getString(c1.getColumnIndex("longitude"));
mylat=mylatitude;
mylon=mylongitude;
} while (c1.moveToNext());
}
}
c1.close();
if(gps.canGetLocation ){
current_latitude=gps.getLatitude();
current_longitude=gps.getLongitude();
}else{
}
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("http://maps.google.com/maps?saddr=" +
current_latitude + "," +
current_longitude + "&daddr=" + mylat + "," + mylon ));
startActivity(intent);
Now, when I press "OK" in order to start navigating , a dialog appears (from google maps) where it says that "some services are not available etc " and it has a button to go to settings in order to activate the services.
But the problem is that it doesn't wait for the user to press the settings button.It just shows up for 1 second and immediately starting to find position (but it can't because services are off).
What should i do for this?Can anyone help please?
Thanks!
I am uploading some screenshots:
The screen to enable GPS :
The screen which starts loading immediately after the previous screen:
Maybe this is some kind of phone's problem?

Related

How to change button text and color in android?

I am making an app in which there is a button and when a user click on that button it will fetch the latitude and longitude of user and prompt to open that using google map and when I click on button it is changing the text and color of button but what I want is when it prompt to open that in maps and if user click outside that view then the button will change to its original text .I am having relative layout and in relative layout I have a method setOnClickListener so that when user click outside button it will change to original bt if the prompt is open then it is not working .`
String uri = "http://maps.google.com/maps?f=d&hl=en&saddr=" + mylatitude + "," + mylongitude + "&daddr=" + locationofuserlat + "," + locationofuserlong;
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(Intent.createChooser(intent, "Select an application"));`
This is my code when it prompts and I click outside that then the button will not change.

How to notify the system setting changed in Android

I develop an app (push to /system/app)and want to modify some system settings, I do like the
public void changeAnimationSettings(boolean isChecked) {
int result1 = isChecked ? 0 : 1;
Settings.Global.putInt(getContentResolver(), Settings.Global.ANIMATOR_DURATION_SCALE, result1);
Settings.Global.putInt(getContentResolver(), Settings.Global.WINDOW_ANIMATION_SCALE, result1);
Settings.Global.putInt(getContentResolver(), Settings.Global.TRANSITION_ANIMATION_SCALE, result1);
Log.i(TAG, "---->>ANIMATOR_DURATION_SCALE: " + Settings.Global.getString(getContentResolver(), Settings.Global.ANIMATOR_DURATION_SCALE));
Log.i(TAG, "---->>WINDOW_ANIMATION_SCALE: " + Settings.Global.getString(getContentResolver(), Settings.Global.WINDOW_ANIMATION_SCALE));
Log.i(TAG, "---->>TRANSITION_ANIMATION_SCALE " + Settings.Global.getString(getContentResolver(), Settings.Global.TRANSITION_ANIMATION_SCALE));
}
the log show the value has changed successful, but
the problem is the modify will not work immediately untill I open the system settings app again .
I guess the value change is not notify to system in my app.

Android - How to launch Google map intent in android app setting both zoom level and marker

My question is very similar to this question (Android - How to launch Google map intent in android app with certain location, zoom level and marker) but the accepted answer is not working for me. It opens the map with the marker at the correct place and at the correct zoom level but then proceeds to zoom in to a street level view (zoom=16 or 17?).
I've search SO, I've read through this documentation but can't find a combination of place marker & zoom that do what I need.
I've tried with a few devices using Google Maps versions
8.2.0,
9.20.1,
9.36.2 &
9.42.3
Here is the result of the log print (the Uri used for the intent)
geo:39.29038619995117,-76.61219024658203?q=39.29038619995117%2C-76.61219024658203(Baltimore)&z=11
The answer from the other post is 4 years old now. Has Maps changed such that this doesn't work now? Did the other answer only work because they were setting the zoom to 17 and didn't notice it wouldn't settle on another zoom level? Am I missing something else?
To clearly state my question:
How can I use a geo intent to open a maps app to show a place marker and simultaneously choose a zoom level?
My code, based on the accepted answer from the other post.
double latitude = item.getLatitude();
double longitude = item.getLongitude();
String label = item.getName();
String uriBegin = "geo:" + latitude + "," + longitude;
String query = latitude + "," + longitude + "(" + label + ")";
String encodedQuery = Uri.encode(query);
String uriString = uriBegin + "?q=" + encodedQuery + "&z=11";
mListener.onListFragmentInteraction(uriString);
Then
public void onListFragmentInteraction(String url) {
Uri geoLocation = Uri.parse(url);
Log.d(TAG, "geo uri = " + geoLocation);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(geoLocation);
startActivity(intent);
}
#Gary99 for removing restaurant u have to add hiding map feature content here is the link(https://developers.google.com/maps/documentation/android-api/hiding-features)
Uri gmmIntentUri = Uri.parse("geo:37.7749,-122.4194?z=10&q=restaurants")
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri)
mapIntent.setPackage("com.google.android.apps.maps")
startActivity(mapIntent)

Android Sygic intent

I followed the instructions at http://dev.sygic.com/documentation/custom-url-schema/ & http://help.sygic.com/entries/22207668-Developers-Only-Sygic-implementation-to-your-app-Android-SDK-iPhone-SDK-Url-Handler-
I am passing the coordinates to Sygic 12.991030334592057 as latitude and 77.80791163444519 as longitude.
Another com.sygic.aura://coordinate|12.9138|77.6680|drive
However Sygic says 'The coordinates are outside the map.'
String str = "http://com.sygic.aura/coordinate|" + latitude + "|"
+ longitude + "|" + type.toString();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));
I also tried
String str = "com.sygic.aura://coordinate|" + latitude + "|"
+ longitude + "|" + type.toString();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));
EDIT:
The type is enum. type.toString shows drive as the string.
What am I doing wrong?
Got the same problem. As enli was saying, the order of the lat,lon params is the opposite. This code worked for me:
String str = "com.sygic.aura://coordinate|" + lon + "|" + lat + "|" + type.toString();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));
in my phone, this example call launched sygic and started navigation:
com.sygic.aura://coordinate|-3.588678|37.176278|drive
Hope it helps
There is nothing wrong with your code. Have you made sure that those values of longitude and latitude are correct? With which application you got those co-ordinates?
I was working on the same code today and it seems that I had used longitude at the place of latitude and vice versa. Try interchanging the co-ordinates. That worked for me when I was in the same boat as yours. If that is not the case, make sure that you have Sygic maps for that location by manually navigating to that location by navigating to that location from Menu > Navigate to... > GPS coordinates.

android Map view Issue

I have made an application containing facility of viewing current location on map. I have used default Map Intent to show map. It Works fine in Emulator but when I am testing in my Android device (motorola Millstone) , Map works fine but after view map, my application is not responding.anyone have any ideas why it happens?
String path = "http://maps.google.com/maps?saddr=" + lat + ","+ lon + "&daddr=" + b_latt + "," + b_lang;
String geoUriString = new String(path);
Uri geoUri = Uri.parse(geoUriString);
Intent mapCall = new Intent(Intent.ACTION_VIEW, geoUri);
startActivity(mapCall);
You want to show One Marker at Current Location,but In the code you shown you are passing two values to draw path..
To show user's Current Location on Map via intent you need to call this way
String uri = "geo:"+ latitude + "," + longitude;
startActivity(new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri)));
You can see More on This Site

Categories

Resources