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 9207443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:23:18+00:00 2026-06-18T00:23:18+00:00

when i first load my app mapActivity is invoking and i can see the

  • 0

when i first load my app mapActivity is invoking and i can see the map, now when i
switch off the networkconnectivity and on again , changing the screen and coming back
to the mapactivity the map is showing null, getting nullpointer exception at this
line new MapUtils().drawMap(this); in onResume() method.

@Override
protected void onResume() {
    Utils utils = new Utils();
    manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    listener = new ManageLocation();

    listener.setSucessCallBack(this, "setLocation");
    listener.setFailureCallBack(this, "setNoLocation");


    manager.requestLocationUpdates(
            utils.getCurrentPlaceLocationProvider(manager), 0, 0,
            listener);
    super.onResume();

    Log.d(TAG, "Constants.isDataLoadedPAB " + Constants.isMaptobeLoaded
            + " Constants.isDataLoadedPAB : " + Constants.isDataLoadedPAB);
    if (Constants.isMaptobeLoaded) {
        if (Constants.isDataLoadedPAB) {
            try {
                new MapUtils().drawMap(this);
            } catch (Exception e) {
                Log.e(TAG, "Error", e);
            }
        } else {
            if (Constants.currentLocation != null
                    && Constants.searchLocation != null) {
                if (Constants.searchResultData == null) {
                    Constants.searchResultData = new ArrayList<AttractionData>();
                }

                new MapUtils().drawMap(this);

            }
            }
    }
    ((ImageView) activity.findViewById(R.id.left)).setEnabled(true);
    ((ImageView) activity.findViewById(R.id.right)).setEnabled(true);   
    ((ImageView) findViewById(R.id.searchicon)).setEnabled(true);

    ((ImageView) activity.findViewById(R.id.facebookintegration)).setEnabled(true);
}

I am trying to invoke it again in onResume() but still getting null.
i am struck not sure where i am doing wrong.Any help is appreciated

my log

01-29 11:23:36.325: E/AndroidRuntime(6668): Caused by: java.lang.NullPointerException
01-29 11:23:36.325: E/AndroidRuntime(6668):     at org.appright.myneighborhood.maps.MapUtils.drawMap(MapUtils.java:59)
01-29 11:23:36.325: E/AndroidRuntime(6668):     at org.appright.myneighborhood.activity.CityAttractions.onResume(CityAttractions.java:505)
01-29 11:23:36.325: E/AndroidRuntime(6668):     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1199)
01-29 11:23:36.325: E/AndroidRuntime(6668):     at android.app.Activity.performResume(Activity.java:5280)
01-29 11:23:36.325: E/AndroidRuntime(6668):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2606)
01-29 11:23:36.325: E/AndroidRuntime(6668):     ... 10 more
  • 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-06-18T00:23:20+00:00Added an answer on June 18, 2026 at 12:23 am

    The problem is with this line

    FrameLayout topLayout = (FrameLayout) activity.findViewById(R.id.map_container);
                        topLayout.removeAllViews();
    

    in MapUtils().drawMap(this);

    what you are doing is to remove all the view from container i.e. FrameLayout map_container
    when network connection not available.

    And when network comes again you are accessing the MapView which you have removed from the layout hierarchy and it wont find the defaultmapView this time and throw NullPionterException.

    Try to comment all the code in else block and just show a toast only. hope it will work. Or try some different logic.

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

Sidebar

Related Questions

I have an app that I load in a uiwebview, it first load a
is there anyway to make the app load the first page every time it's
If I have an app and it is run inside facebook. the first load
I am new to the android programming. In My app I first load splash
In C# Winforms, while user first load the form, I get the input as
Sometimes the header of my website does not form properly when I first load
js doesn't work if I don't refresh the page after first load,and div's background-img
I've in the following code the progressbar working on the first page load. after
The first page I load from my site after not visiting it for 20+
I called $('#tabs').tabs('load',0) to load the first tab, and the server return a response

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.