Show location On Map - Android Map

Android examples for Map:Google Map

Description

Show location On Map

Demo Code


//package com.java2s;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import android.content.Intent;
import android.net.Uri;
import android.util.Log;

public class Main {
    public static Intent viewOnMap(String address) {
        try {/*from w  w  w .  jav  a  2 s  .c o  m*/
            return new Intent(Intent.ACTION_VIEW, Uri.parse(String.format(
                    "geo:0,0?q=%s", URLEncoder.encode(address, "utf-8"))));
        } catch (UnsupportedEncodingException e) {
            Log.e("mcall-error", e.getMessage(), e);
            throw new IllegalStateException(e);
        }
    }

    public static Intent viewOnMap(String lat, String lng) {
        return new Intent(Intent.ACTION_VIEW, Uri.parse(String.format(
                "geo:%s,%s", lat, lng)));
    }
}

Related Tutorials