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

  • Home
  • SEARCH
  • 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 7575111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:36:18+00:00 2026-05-30T16:36:18+00:00

I have followed the code provided by Google concerning implemeting a Web Map Activity,

  • 0

I have followed the code provided by Google concerning implemeting a Web Map Activity, i understood all the code but when launching the Activity i have a Java Null Pointer Exception, i think that it doesn’t finds latitude and longitude to show, i don’t know how to solve that problem. here is the code:

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        getLocation();
        setupWebView();
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
      }


      private void setupWebView(){
//        mostRecentLocation.setLatitude(36.848427);
//        mostRecentLocation.setLongitude(10.26829);
          final String centerURL = "javascript:centerAt(" +
          mostRecentLocation.getLatitude() + "," +
          mostRecentLocation.getLongitude()+ ")";
          webView = (WebView) findViewById(R.id.webview);
          webView.getSettings().setJavaScriptEnabled(true);
          //Wait for the page to load then send the location information
          webView.setWebViewClient(new WebViewClient());
          webView.loadUrl(MAP_URL);
          /** Allows JavaScript calls to access application resources **/
          webView.addJavascriptInterface(new JavaScriptInterface(), "android");
        }

logcat indicates that the problem is in the setupWebView() function.
Thank you for helping.
Logcat:

02-29 13:06:42.284: E/AndroidRuntime(642): FATAL EXCEPTION: main
02-29 13:06:42.284: E/AndroidRuntime(642): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.powerful/com.android.powerful.WebMapActivity}: java.lang.NullPointerException
02-29 13:06:42.284: E/AndroidRuntime(642):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
02-29 13:06:42.284: E/AndroidRuntime(642):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-29 13:06:42.284: E/AndroidRuntime(642):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-29 13:06:42.284: E/AndroidRuntime(642):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-29 13:06:42.284: E/AndroidRuntime(642):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-29 13:06:42.284: E/AndroidRuntime(642):  at android.os.Looper.loop(Looper.java:130)
02-29 13:06:42.284: E/AndroidRuntime(642):  at android.app.ActivityThread.main(ActivityThread.java:3683)
02-29 13:06:42.284: E/AndroidRuntime(642):  at java.lang.reflect.Method.invokeNative(Native Method)
02-29 13:06:42.284: E/AndroidRuntime(642):  at java.lang.reflect.Method.invoke(Method.java:507)
02-29 13:06:42.284: E/AndroidRuntime(642):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-29 13:06:42.284: E/AndroidRuntime(642):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-29 13:06:42.284: E/AndroidRuntime(642):  at dalvik.system.NativeStart.main(Native Method)
02-29 13:06:42.284: E/AndroidRuntime(642): Caused by: java.lang.NullPointerException
02-29 13:06:42.284: E/AndroidRuntime(642):  at com.android.powerful.WebMapActivity.setupWebView(WebMapActivity.java:30)
02-29 13:06:42.284: E/AndroidRuntime(642):  at com.android.powerful.WebMapActivity.onCreate(WebMapActivity.java:24)
02-29 13:06:42.284: E/AndroidRuntime(642):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-29 13:06:42.284: E/AndroidRuntime(642):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
  • 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-30T16:36:19+00:00Added an answer on May 30, 2026 at 4:36 pm

    mostRecentLocation is probably null.
    That’s why when you try to access getLatitude you get the exception.
    I don’t see you initializing mostRecentLocation in the code you posted

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

Sidebar

Related Questions

I have followed the instructions found at http://code.google.com/p/pubsubhubbub/wiki/DeveloperGettingStartedGuide to setup a hub. When I
I have got this code and I am trying to understand the convention followed,
I have followed all the instructions here: http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/ to install & config apache get
I have implemented an asynchronous http listener in c#. I followed the tutorial provided
I have followed the instructions for installing the Google App Engine SDK Eclipse plugin:
I have followed the instructions on the jQuery site to close jQuery tabs but
First of all my apologies to those of you who would have followed my
I wrote this code. I followed the sample application code provided with facebook SDK.
I have followed the blog post written by Steve Sanderson at blog.codeville.net/2008/10/14/partial-requests-in-aspnet-mvc . It
I have followed the suggestion in this question... [ How to handle checkboxes in

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.