Win a copy of Getting started with Java programming language this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getSupportFragmentManager returns null in certain devices  RSS feed

 
achuthan mukundarajan
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on a project with google maps.I use the following code for getting the google map object:



This code works fine on most devices, but on certain devices the googleMap object returns as null and it shows a NPE further down in the code.What am i doing wrong?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What returns null - getSupportFragmentManager() or findFragmentById(R.id.map) ?
 
achuthan mukundarajan
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I changed the single line of code


as the following:





The last line is the one which is causing the issue.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like the findFragmentById call returns null. Does "R.id.map" exist in the current view?
 
achuthan mukundarajan
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Sounds like the findFragmentById call returns null. Does "R.id.map" exist in the current view?


yes the map exsists as a fragment.Also the app runs fine on my device(Android 2.6.3).But on certain other devices it doesn't run.The xml is shown below.




 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do those other devices have Google Maps installed? I'm guessing that com.google.android.gms.maps.SupportMapFragment would not be available if they don't.
 
achuthan mukundarajan
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Do those other devices have Google Maps installed? I'm guessing that com.google.android.gms.maps.SupportMapFragment would not be available if they don't.


They do have google maps installed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!