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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:13:15+00:00 2026-06-15T18:13:15+00:00

I have a Fragment which Extends SupportMapFragment. public class PlaceMapsFragment extends SupportMapFragment { private

  • 0

I have a Fragment which Extends SupportMapFragment.

public class PlaceMapsFragment extends SupportMapFragment {
    private GoogleMap mMap;
    private LatLng mPosFija;

    public PlaceMapsFragment() {
        super();
    }

    public static PlaceMapsFragment newInstance(LatLng posicion) {
        PlaceMapsFragment frag = new PlaceMapsFragment();
        frag.mPosFija = posicion;
        return frag;
    }

    @Override
    public GoogleMap getMap() {
        // TODO Auto-generated method stub
        return super.getMap();
    }

    @Override
    public void onCreate(Bundle arg0) {
        // TODO Auto-generated method stub
        super.onCreate(arg0);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = super.onCreateView(inflater, container, savedInstanceState);
        //initMap();
        return view;
    }

    private void initMap() {
        UiSettings settings = getMap().getUiSettings();
        settings.setAllGesturesEnabled(false);
        settings.setMyLocationButtonEnabled(false);

        getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(mPosFija, 16));
        getMap().addMarker(
                new MarkerOptions().position(mPosFija)
                        .icon(BitmapDescriptorFactory
                                .fromResource(R.drawable.marker)));
    }

}

Now i want to refernce the MapView that is automatically generated so that i can add my functionality to the map.

When i try to initMap(); i get NullPointerException

Error:

12-10 02:54:20.171: E/AndroidRuntime(4339): FATAL EXCEPTION: main
12-10 02:54:20.171: E/AndroidRuntime(4339): java.lang.NullPointerException
12-10 02:54:20.171: E/AndroidRuntime(4339):     at maps.ar.b.a(Unknown Source)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at maps.y.h.a(Unknown Source)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at maps.y.au.a(Unknown Source)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at maps.y.ae.moveCamera(Unknown Source)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at com.google.android.gms.maps.internal.IGoogleMapDelegate$Stub.onTransact(IGoogleMapDelegate.java:83)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at android.os.Binder.transact(Binder.java:297)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at com.google.android.gms.maps.internal.IGoogleMapDelegate$a$a.moveCamera(Unknown Source)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at com.google.android.gms.maps.GoogleMap.moveCamera(Unknown Source)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at com.m7.nomad.PlaceMapsFragment.initMap(PlaceMapsFragment.java:55)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at com.m7.nomad.PlaceMapsFragment.onCreateView(PlaceMapsFragment.java:46)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:461)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at com.m7.nomad.PlaceActivity$TabManager.onTabChanged(PlaceActivity.java:153)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at android.widget.TabHost.invokeOnTabChangeListener(TabHost.java:379)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at android.widget.TabHost.setCurrentTab(TabHost.java:364)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:150)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:540)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at android.view.View.performClick(View.java:3591)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at android.view.View$PerformClick.run(View.java:14263)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at android.os.Handler.handleCallback(Handler.java:605)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at android.os.Handler.dispatchMessage(Handler.java:92)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at android.os.Looper.loop(Looper.java:137)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at android.app.ActivityThread.main(ActivityThread.java:4507)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at java.lang.reflect.Method.invokeNative(Native Method)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at java.lang.reflect.Method.invoke(Method.java:511)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
12-10 02:54:20.171: E/AndroidRuntime(4339):     at dalvik.system.NativeStart.main(Native Method)
  • 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-15T18:13:16+00:00Added an answer on June 15, 2026 at 6:13 pm

    This is an expected behabiour.

    You can call getMap() only after the Fragment has gone through onCreateView(), otherwise it will give you a null. You can also receive a null if the Google Play Services is not available.

    In other words, call initMap() in onResume().

    You can check more here.

    Hope it helps!

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

Sidebar

Related Questions

Suppose I have several fragments : public class FirstFragment extends Fragment { ... }
Lets say I have a Fragment defined as such: public class MyFragment extends Fragment
I have a generic class which represents a fragment of text. That fragment of
I have a Fragment which extends ListFragment, this is added at runtime to a
I have 3 fragments in my activity, managed by a custom class which extends
I hava a fragment named DetailFragment which extends Fragment class with neccessary Override methods:
I'm writing a class which extends Fragment and I would like to use it
I have a HTML fragment which contains two anchor tags in various parts of
I have a fragment of html which is contained in a property of a
Lets say you have a fragment of the page which displays the most recent

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.