Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6945049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:23:09+00:00 2026-05-27T13:23:09+00:00

I am using the following map class to use maps in my android app…

  • 0

I am using the following map class to use maps in my android app…

 package com.wglxy.example.dash1;

import java.io.IOException;
import java.util.List;

import android.app.AlertDialog;
import android.content.Intent;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class map extends MapActivity {

    private MapView mapview;
    private Geocoder geocoder;
    private Button map1;
    String[] myadd;
    private int len;
    private GeoPoint p;
    private MapController controller;
    private TextView helloText;
    private List<Address> addresses;
    private int i;
    private String[] mynames;
    private ImageButton info;
    private String[] citysearch7 = new String[1];
    private ImageButton search;
    private ImageButton home;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.map);

        Intent intent = getIntent();
        myadd = intent.getStringArrayExtra("strings");
        mynames = intent.getStringArrayExtra("names");
        info = (ImageButton) findViewById(R.id.info);
        search = (ImageButton) findViewById(R.id.search1);
        home = (ImageButton) findViewById(R.id.hom);
        len = myadd.length;
        System.out.println("Length=" + len);
        mapview = (MapView) findViewById(R.id.mapview);
        mapview.setBuiltInZoomControls(true);
        geocoder = new Geocoder(this);
    //  check();
        while (i != len) {
            try {
                System.out.println("Coming inside try catch and adress="
                        + myadd[i]);

                addresses = geocoder
                        .getFromLocationName(myadd[i].toString(), 1);

            } catch (IOException e) {
                System.out.println("Catching");
                e.printStackTrace();
            }

            if (addresses.size() > 0) {
                p = new GeoPoint((int) (addresses.get(0).getLatitude() * 1E6),
                        (int) (addresses.get(0).getLongitude() * 1E6));

                controller = mapview.getController();
                controller.setZoom(12);

                MapOverlay mapOverlay = new MapOverlay(map.this, p, mynames[i]);
                List<Overlay> listOfOverlays = mapview.getOverlays();
                listOfOverlays.add(mapOverlay);

                controller.animateTo(p, new Runnable() {
                    public void run() {
                        controller.setZoom(12);
                    }
                });
                mapview.invalidate();

            } else {
                AlertDialog.Builder adb = new AlertDialog.Builder(map.this);
                adb.setTitle("Google Map");
                adb.setMessage("Please Provide the Proper Place");
                adb.setPositiveButton("Close", null);
                adb.show();
            }
            i++;
        }

    }

    void check() {
        info.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                startActivity(new Intent(getApplicationContext(),
                        AboutActivity.class));
            }
        });
        home.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent intent = new Intent(getApplicationContext(), start.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
            }
        });
        search.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent intent = new Intent(getApplicationContext(),
                        search.class);
                startActivity(intent);
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.bloodmenu:
            startActivity(new Intent(getApplicationContext(), search.class));
            break;
        case R.id.bankmenu:
            citysearch7[0] = "";
            Intent intent = new Intent(getApplicationContext(),
                    searchbank.class);
            intent.putExtra("search", citysearch7);
            startActivity(intent);
            break;
        case R.id.updatemenu:
            startActivity(new Intent(getApplicationContext(), update.class));
            break;
        case R.id.registermenu:
            Intent intent1 = new Intent(getApplicationContext(), register.class);
            Bundle b = new Bundle();
            b.putString("name", "");
            b.putString("house", "");
            b.putString("street", "");
            b.putString("city", "");
            b.putString("blood", "");
            b.putString("phone", "");
            b.putString("file", "register");
            intent1.putExtras(b);
            startActivity(intent1);
            break;
        }
        return true;
    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }

}

but it gives an error. The log of which is as follows:

D/dalvikvm(  466): GC_FOR_MALLOC freed 8171 objects / 631112 bytes in 54ms

D/dalvikvm(  466): GC_FOR_MALLOC freed 6139 objects / 371288 bytes in 55ms

I/System.out(  466): Length=3

I/System.out(  466): Coming inside try catch and adress=Surya Nagar Agra

I/System.out(  466): Catching

W/System.err(  466): java.io.IOException: Service not Available

W/System.err(  466):    at android.location.Geocoder.getFromLocationName(Geocoder.java:159)

W/System.err(  466):    at com.wglxy.example.dash1.map.onCreate(map.java:68)

W/System.err(  466):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)

W/System.err(  466):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)

W/System.err(  466):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)

W/System.err(  466):    at android.app.ActivityThread.access$2300(ActivityThread.java:125)

W/System.err(  466):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)

W/System.err(  466):    at android.os.Handler.dispatchMessage(Handler.java:99)

W/System.err(  466):    at android.os.Looper.loop(Looper.java:123)

W/System.err(  466):    at android.app.ActivityThread.main(ActivityThread.java:4627)

W/System.err(  466):    at java.lang.reflect.Method.invokeNative(Native Method)

W/System.err(  466):    at java.lang.reflect.Method.invoke(Method.java:521)

W/System.err(  466):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)

W/System.err(  466):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)

W/System.err(  466):    at dalvik.system.NativeStart.main(Native Method)

D/AndroidRuntime(  466): Shutting down VM

W/dalvikvm(  466): threadid=1: thread exiting with uncaught exception (group=0x4001d800)

E/AndroidRuntime(  466): FATAL EXCEPTION: main

E/AndroidRuntime(  466): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wglxy.example.dash1/com.wglxy.example.dash1.map}: java.lang.NullPointerException

E/AndroidRuntime(  466):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)

E/AndroidRuntime(  466):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)

E/AndroidRuntime(  466):    at android.app.ActivityThread.access$2300(ActivityThread.java:125)

E/AndroidRuntime(  466):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)

E/AndroidRuntime(  466):    at android.os.Handler.dispatchMessage(Handler.java:99)

E/AndroidRuntime(  466):    at android.os.Looper.loop(Looper.java:123)

E/AndroidRuntime(  466):    at android.app.ActivityThread.main(ActivityThread.java:4627)

E/AndroidRuntime(  466):    at java.lang.reflect.Method.invokeNative(Native Method)

E/AndroidRuntime(  466):    at java.lang.reflect.Method.invoke(Method.java:521)

E/AndroidRuntime(  466):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)

E/AndroidRuntime(  466):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)

E/AndroidRuntime(  466):    at dalvik.system.NativeStart.main(Native Method)

E/AndroidRuntime(  466): Caused by: java.lang.NullPointerException

E/AndroidRuntime(  466):    at com.wglxy.example.dash1.map.onCreate(map.java:75)

E/AndroidRuntime(  466):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)

E/AndroidRuntime(  466):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)

E/AndroidRuntime(  466):    ... 11 more

W/ActivityManager(   70):   Force finishing activity com.wglxy.example.dash1/.map

W/ActivityManager(   70):   Force finishing activity com.wglxy.example.dash1/.search

W/ActivityManager(   70): Activity pause timeout for HistoryRecord{44efd6a8 com.wglxy.example.dash1/.map}

W/ActivityManager(   70): Launch timeout has expired, giving up wake lock!

W/ActivityManager(   70): Activity idle timeout for HistoryRecord{44ed9bb8 com.wglxy.example.dash1/.start}

W/ActivityManager(   70): Activity destroy timeout for HistoryRecord{44edc6e8 com.wglxy.example.dash1/.search}

W/ActivityManager(   70): Activity destroy timeout for HistoryRecord{44efd6a8 com.wglxy.example.dash1/.map}

D/dalvikvm(  275): GC_EXPLICIT freed 1903 objects / 139672 bytes in 196ms

D/dalvikvm(  407): GC_EXPLICIT freed 119 objects / 9440 bytes in 130ms

D/dalvikvm(  416): GC_EXPLICIT freed 635 objects / 50232 bytes in 145ms

D/dalvikvm(  196): GC_EXPLICIT freed 808 objects / 45672 bytes in 176ms

Please consider the print statements that I have used and using that could anyone please help me understand my problem?? I also changed my key and updated but in vain. Is there something wrong with my emulator, I also tried creating a new fresh emulator but it still doesn’t work. Also i have commented the line which calls the check() method, is there a problem if i do not comment it?
-Please help…thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:23:10+00:00Added an answer on May 27, 2026 at 1:23 pm

    you should have searched for the error..and you will find many like

    Android; Geocoder, why do I get "the service is not available"?

    and

    Why is Android Geocoder throwing a "Service not Available" exception?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following example (using JUnit with Hamcrest matchers): Map<String, Class<? extends Serializable>> expected
I have displayed the map in my app by using the following code. I
When I use the following #include <map> using namespace LCDControl; Any reference to the
Following Mootools class helps developer to draw a circle overlay on Google Map using
Trying to map the following schema using the Entity Framework. A Customer can have
I am using following class to show a grid like appearance with pagination on
I have a file that contains the following: #include <map> class A {}; void
I find myself using a lot of nested maps, e.g a Map[Int, Map[String, Set[String]]],
I'm following this tutorial and declare the following mappings in my app delegate: [map
Using NHibernate 3.2 ByCode configuration, I am attempting to map the following hierarchical entity:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.