Skip to main content

Google Maps Intents Sketchware



Intent

Intents 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 Intent 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:


  1. Display a map at a specified location and zoom level.
  2. Search for locations or places, and display them on a map.
  3. Request directions from one location to another. Directions can be returned for three modes of transportation: driving, walking, bicycling.
  4. Display panorama imagery in Google Street View.

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 requests

In order to launch Google Maps with an intent you must first create an Intent object, specifying its action, URI and package.
  • Action: All Google Maps intents are called as a View action — ACTION_VIEW.
  • URI: Google Maps intents use URI encoded strings that specify a desired action, along with some data with which to perform the action.
  • Package: Calling setPackage("com.google.android.apps.maps") will ensure that the Google Maps app for Android handles the Intent. If the package isn't set, the system will determine which apps can handle the Intent. If multiple apps are available, the user may be asked which app they would like to use.

Open map apps through intent


Procedure:

1. Create a new project and open it.
2. Add edit text and button to your view


3. Create a string variable named (name).
4. Add the string block and ASD block to On click event showed in the diagram(follow the diagram).


4. Add this code to your ASD block.

Code:

intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse(name));
intent.setPackage("com.google.android.apps.maps");
 startActivity(intent);

5. Run Your app.

You can watch the video with this link:-

Comments

Post a Comment

Popular posts from this blog

Edittext Floating Hint in Sketchware

Code  :  EditText editText = new EditText(this); LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); com.google.android.material.textfield.TextInputLayout textInputLayout = new com.google.android.material.textfield.TextInputLayout(this); LinearLayout.LayoutParams textInputLayoutParams = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); textInputLayout.setLayoutParams(textInputLayoutParams); textInputLayout.addView(editText, editTextParams); textInputLayout.setHint("Your Name"); // Your view Code here

Pinch-to-zoom with multi-touch gestures In Sketchware

We will demonstrate multi-touch with the common pinch-to-zoom gesture. The following screen-shot shows the icon zoomed in and out using the application created : Zoom in Zoom out Let's get started! 1. Create a new project. 2. Add an imageview widget to your view (you can use any image of your choice). 3. Create a block and name it (zoom_in_out). 4. Add this code to your block. } private ScaleGestureDetector mScaleGestureDetector; private float mScaleFactor = 1.0f; public boolean onTouchEvent(MotionEvent motionEvent) { mScaleGestureDetector.onTouchEvent(motionEvent); return true; } { } private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener { @Override public boolean onScale(ScaleGestureDetector scaleGestureDetector){mScaleFactor *= scaleGestureDetector.getScaleFactor(); mScaleFactor = Math.max(0.1f,Math.min(mScaleFactor, 10.0f)); imageview1.setScaleX(mScaleFactor); imageview1.setScaleY(mScaleFactor);return true; } } { 5. Add this code to your OnCreate ...