Redmi note 7 lỗi google map site c.mi.com
The Google Maps app for Android exposes several intents that you can use to launch Google Maps in display, search, navigation, or Street View modes. If you want to embed a map in your app, please refer to the Google Maps Android API Getting Started Guide. Show OverviewIntents let you start an activity in another app by describing a simple action you'd like to perform (such as "display a map" or "show directions to the airport") in an mapIntent.resolveActivity(packageManager)?.let { ... } 8 object. The Google Maps app for Android supports several different intents, allowing you to launch the Google Maps app and perform one of four actions:
This page describes the intents that you can use with Google Maps app for Android. For more information on Intents and Intent Filters, or Intents common to the Android platform, refer to the Android developer documentation. Intent requestsIn order to launch Google Maps with an intent you must first create an mapIntent.resolveActivity(packageManager)?.let { ... } 8 object, specifying its action, URI and package.
After creating the mapIntent.resolveActivity(packageManager)?.let { ... } 8, you can request that the system launch the related app in a number of ways. A common method is to pass the mapIntent.resolveActivity(packageManager)?.let { ... } 8 to the method. The system will launch the necessary app — in this case Google Maps — and start the corresponding Uri gmmIntentUri = Uri.parse("geo:37.7749,-122.4194"); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps"); if (mapIntent.resolveActivity(getPackageManager()) != null) { startActivity(mapIntent); } 6. Java// Create a Uri from an intent string. Use the result to create an Intent. Uri gmmIntentUri = Uri.parse("google.streetview:cbll=46.414382,10.013988"); // Create an Intent from gmmIntentUri. Set the action to ACTION_VIEW Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); // Make the Intent explicit by setting the Google Maps package mapIntent.setPackage("com.google.android.apps.maps"); // Attempt to start an activity that can handle the Intent startActivity(mapIntent); Kotlin// Create a Uri from an intent string. Use the result to create an Intent. val gmmIntentUri = Uri.parse("google.streetview:cbll=46.414382,10.013988") // Create an Intent from gmmIntentUri. Set the action to ACTION_VIEW val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) // Make the Intent explicit by setting the Google Maps package mapIntent.setPackage("com.google.android.apps.maps") // Attempt to start an activity that can handle the Intent startActivity(mapIntent) If the system cannot identify an app that can respond to the intent, your app may crash. For this reason, you should first verify that a receiving application is installed before you present one of these intents to a user. To verify that an app is available to receive the intent, call on your mapIntent.resolveActivity(packageManager)?.let { ... } 8 object. If the result is non-null, there is at least one app that can handle the intent and it's safe to call . If the result is val gmmIntentUri = Uri.parse("geo:37.7749,-122.4194") val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) mapIntent.setPackage("com.google.android.apps.maps") mapIntent.resolveActivity(packageManager)?.let { startActivity(mapIntent) } 0, you should not use the intent and, if possible, you should disable the feature that invokes the intent. Javaif (mapIntent.resolveActivity(getPackageManager()) != null) { ... } KotlinmapIntent.resolveActivity(packageManager)?.let { ... } For example, to display a map of San Francisco, you can use the following code: JavaUri gmmIntentUri = Uri.parse("geo:37.7749,-122.4194"); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps"); if (mapIntent.resolveActivity(getPackageManager()) != null) { startActivity(mapIntent); } Kotlinval gmmIntentUri = Uri.parse("geo:37.7749,-122.4194") val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) mapIntent.setPackage("com.google.android.apps.maps") mapIntent.resolveActivity(packageManager)?.let { startActivity(mapIntent) } URL encoded query stringsAll strings passed to the Google Maps Intents must be URI encoded. For example, the string "1st & Pike, Seattle" should become val gmmIntentUri = Uri.parse("geo:37.7749,-122.4194") val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) mapIntent.setPackage("com.google.android.apps.maps") mapIntent.resolveActivity(packageManager)?.let { startActivity(mapIntent) } 1. Spaces in the string can be encoded with %20 or replaced with the plus sign (+). You can use the val gmmIntentUri = Uri.parse("geo:37.7749,-122.4194") val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) mapIntent.setPackage("com.google.android.apps.maps") mapIntent.resolveActivity(packageManager)?.let { startActivity(mapIntent) } 2 val gmmIntentUri = Uri.parse("geo:37.7749,-122.4194") val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) mapIntent.setPackage("com.google.android.apps.maps") mapIntent.resolveActivity(packageManager)?.let { startActivity(mapIntent) } 3 method to encode your strings. For example: JavaUri gmmIntentUri = Uri.parse("geo:37.7749,-122.4192?q=" + Uri.encode("1st & Pike, Seattle")); Kotlinval gmmIntentUri = Uri.parse("geo:37.7749,-122.4192?q=" + Uri.encode("1st & Pike, Seattle")) Displaying a mapUse the val gmmIntentUri = Uri.parse("geo:37.7749,-122.4194") val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) mapIntent.setPackage("com.google.android.apps.maps") mapIntent.resolveActivity(packageManager)?.let { startActivity(mapIntent) } 4 intent to display a map at a specified location and zoom level. geo:latitude,longitude?z=zoom Parameters
Examples Java// Creates an Intent that will load a map of San Francisco Uri gmmIntentUri = Uri.parse("geo:37.7749,-122.4194"); Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); mapIntent.setPackage("com.google.android.apps.maps"); startActivity(mapIntent); Kotlin// Create a Uri from an intent string. Use the result to create an Intent. val gmmIntentUri = Uri.parse("google.streetview:cbll=46.414382,10.013988") // Create an Intent from gmmIntentUri. Set the action to ACTION_VIEW val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) // Make the Intent explicit by setting the Google Maps package mapIntent.setPackage("com.google.android.apps.maps") // Attempt to start an activity that can handle the Intent startActivity(mapIntent) 0 Searching for a locationUse this intent to display search queries within a specified viewport. When the query has a single result, you can use this intent to display a pin at a particular place or address, such as a landmark, business, geographic feature, or town. // Create a Uri from an intent string. Use the result to create an Intent. val gmmIntentUri = Uri.parse("google.streetview:cbll=46.414382,10.013988") // Create an Intent from gmmIntentUri. Set the action to ACTION_VIEW val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) // Make the Intent explicit by setting the Google Maps package mapIntent.setPackage("com.google.android.apps.maps") // Attempt to start an activity that can handle the Intent startActivity(mapIntent) 1 Parameters In addition to the parameters used to display a map, Search supports the following parameters:
Categorical searchIf you pass a general search term, Google Maps will attempt to find a location near the lat/lng you specified that matches your criteria. If no location is specified, Google Maps will try to find nearby listings. For example: Java// Create a Uri from an intent string. Use the result to create an Intent. val gmmIntentUri = Uri.parse("google.streetview:cbll=46.414382,10.013988") // Create an Intent from gmmIntentUri. Set the action to ACTION_VIEW val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) // Make the Intent explicit by setting the Google Maps package mapIntent.setPackage("com.google.android.apps.maps") // Attempt to start an activity that can handle the Intent startActivity(mapIntent) 2 Kotlin// Create a Uri from an intent string. Use the result to create an Intent. val gmmIntentUri = Uri.parse("google.streetview:cbll=46.414382,10.013988") // Create an Intent from gmmIntentUri. Set the action to ACTION_VIEW val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) // Make the Intent explicit by setting the Google Maps package mapIntent.setPackage("com.google.android.apps.maps") // Attempt to start an activity that can handle the Intent startActivity(mapIntent) 3 You can further bias the search results by specifying a zoom parameter along with the query string. In the below example, adding a zoom of 10 will attempt to find restaurants at a city level instead of nearby. Java// Create a Uri from an intent string. Use the result to create an Intent. val gmmIntentUri = Uri.parse("google.streetview:cbll=46.414382,10.013988") // Create an Intent from gmmIntentUri. Set the action to ACTION_VIEW val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) // Make the Intent explicit by setting the Google Maps package mapIntent.setPackage("com.google.android.apps.maps") // Attempt to start an activity that can handle the Intent startActivity(mapIntent) 4 Kotlin// Create a Uri from an intent string. Use the result to create an Intent. val gmmIntentUri = Uri.parse("google.streetview:cbll=46.414382,10.013988") // Create an Intent from gmmIntentUri. Set the action to ACTION_VIEW val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) // Make the Intent explicit by setting the Google Maps package mapIntent.setPackage("com.google.android.apps.maps") // Attempt to start an activity that can handle the Intent startActivity(mapIntent) 5 Location searchSearching for a specific address will display a pin at that location. Java// Create a Uri from an intent string. Use the result to create an Intent. val gmmIntentUri = Uri.parse("google.streetview:cbll=46.414382,10.013988") // Create an Intent from gmmIntentUri. Set the action to ACTION_VIEW val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) // Make the Intent explicit by setting the Google Maps package mapIntent.setPackage("com.google.android.apps.maps") // Attempt to start an activity that can handle the Intent startActivity(mapIntent) 6 Kotlin// Create a Uri from an intent string. Use the result to create an Intent. val gmmIntentUri = Uri.parse("google.streetview:cbll=46.414382,10.013988") // Create an Intent from gmmIntentUri. Set the action to ACTION_VIEW val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) // Make the Intent explicit by setting the Google Maps package mapIntent.setPackage("com.google.android.apps.maps") // Attempt to start an activity that can handle the Intent startActivity(mapIntent) 7 The above example sets a lat/lng of Uri gmmIntentUri = Uri.parse("geo:37.7749,-122.4192?q=" + Uri.encode("1st & Pike, Seattle")); 2, Uri gmmIntentUri = Uri.parse("geo:37.7749,-122.4192?q=" + Uri.encode("1st & Pike, Seattle")); 2, but passes an address as a query string. When searching for a very specific location, the latitude and longitude are not required. However, if you do not know the exact address, you can attempt to bias the results of the search by specifying a coordinate. For example, performing an address search for 'Main Street' will return too many results. Java// Create a Uri from an intent string. Use the result to create an Intent. val gmmIntentUri = Uri.parse("google.streetview:cbll=46.414382,10.013988") // Create an Intent from gmmIntentUri. Set the action to ACTION_VIEW val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) // Make the Intent explicit by setting the Google Maps package mapIntent.setPackage("com.google.android.apps.maps") // Attempt to start an activity that can handle the Intent startActivity(mapIntent) 8 Kotlin// Create a Uri from an intent string. Use the result to create an Intent. val gmmIntentUri = Uri.parse("google.streetview:cbll=46.414382,10.013988") // Create an Intent from gmmIntentUri. Set the action to ACTION_VIEW val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) // Make the Intent explicit by setting the Google Maps package mapIntent.setPackage("com.google.android.apps.maps") // Attempt to start an activity that can handle the Intent startActivity(mapIntent) 9 Adding a lat/lng to the intent URI will bias the results towards a particular area: Javaif (mapIntent.resolveActivity(getPackageManager()) != null) { ... } 0 Kotlinif (mapIntent.resolveActivity(getPackageManager()) != null) { ... } 1 When you know your search will return a single value, you may wish to pass an optional label. Labels must be specified as a String, and will appear under the map marker. Note that labels are only available when val gmmIntentUri = Uri.parse("geo:37.7749,-122.4194") val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) mapIntent.setPackage("com.google.android.apps.maps") mapIntent.resolveActivity(packageManager)?.let { startActivity(mapIntent) } 8 is specified as a lat/lng coordinate. Javaif (mapIntent.resolveActivity(getPackageManager()) != null) { ... } 2 Kotlinif (mapIntent.resolveActivity(getPackageManager()) != null) { ... } 3 As an alternative to a street address or a latitude/longitude, you can display a pin at a known location using a plus code. Javaif (mapIntent.resolveActivity(getPackageManager()) != null) { ... } 4 Kotlinif (mapIntent.resolveActivity(getPackageManager()) != null) { ... } 5 Launching turn-by-turn navigationUse this intent to launch Google Maps navigation with turn-by-turn directions to the address or coordinate specified. Directions are always given from the user's current location. if (mapIntent.resolveActivity(getPackageManager()) != null) { ... } 6 Parameters
Examples The below mapIntent.resolveActivity(packageManager)?.let { ... } 8 will request turn-by-turn navigation to Taronga Zoo, in Sydney Australia: Javaif (mapIntent.resolveActivity(getPackageManager()) != null) { ... } 7 Kotlinif (mapIntent.resolveActivity(getPackageManager()) != null) { ... } 8 If you prefer not to pay tolls or ride a ferry, you can request routing that tries to avoid those things. Javaif (mapIntent.resolveActivity(getPackageManager()) != null) { ... } 9 KotlinmapIntent.resolveActivity(packageManager)?.let { ... } 0 If you'd prefer a bit of exercise, you can request bicycling directions instead. JavamapIntent.resolveActivity(packageManager)?.let { ... } 1 KotlinmapIntent.resolveActivity(packageManager)?.let { ... } 2 If you'd prefer taking a motorized two-wheeler, you can request that the directions include narrow roads and trails unavailable to cars. The below val gmmIntentUri = Uri.parse("geo:37.7749,-122.4192?q=" + Uri.encode("1st & Pike, Seattle")) 6 returns a route in India. JavamapIntent.resolveActivity(packageManager)?.let { ... } 3 KotlinmapIntent.resolveActivity(packageManager)?.let { ... } 4 Displaying a Street View panoramaUse the val gmmIntentUri = Uri.parse("geo:37.7749,-122.4192?q=" + Uri.encode("1st & Pike, Seattle")) 7 intent to launch Google Street View. Google Street View provides panoramic views from designated locations throughout its . User contributed Photospheres, and Street View special collections are also available. mapIntent.resolveActivity(packageManager)?.let { ... } 5 Parameters All val gmmIntentUri = Uri.parse("geo:37.7749,-122.4192?q=" + Uri.encode("1st & Pike, Seattle")) 7 URIs must include either a val gmmIntentUri = Uri.parse("geo:37.7749,-122.4192?q=" + Uri.encode("1st & Pike, Seattle")) 9 or a geo:latitude,longitude?z=zoom 0 parameter.
geo:latitude,longitude?z=zoom 7 is an optional parameter that adjusts the initial orientation of the camera. The geo:latitude,longitude?z=zoom 7 parameter takes 5 comma-separated values, all of which are optional. The most significant values are the second, fourth and fifth which set the bearing, zoom and tilt respectively. The first and third values are not supported, and should be set to Uri gmmIntentUri = Uri.parse("geo:37.7749,-122.4192?q=" + Uri.encode("1st & Pike, Seattle")); 2. |