I want to display some point in the map , but when I set the camera on a map why this error occurs ? If this goes wrong with the order CameraUpdateFactory program , previously I did not experience an error
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bongkorr/com.hospifinder.Maps}: java.lang.NullPointerException: CameraUpdateFactory is not initialized
Full is The draft code of CameraUpdateFactory , is there something wrong with this ?
Maps.java
public class Maps<Passing> extends FragmentActivity implements LocationListener {
private GoogleMap map;
private DBAdapter dbhelper;
private SQLiteDatabase db = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
dbhelper = new DBAdapter(this);
db = dbhelper.getWritableDatabase();
dbhelper.delAllData(db);
//dbhelper.delAllData2(db);
dbhelper.generateDataLokasi(db);
dbhelper.generateDataRS(db);
setContentView(R.layout.maps);
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
map = fm.getMap();
map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-6.604345,
106.796640), 12));
map.setMyLocationEnabled(true);
Cursor c = dbhelper.fetchAllLokasi(db);
int col = dbhelper.fetchAllLokasi(db).getCount();
if (col == 0) {
Toast.makeText(Maps.this, "Pas de donnees ", Toast.LENGTH_LONG)
.show();
} else {
c.moveToFirst();
while (c.isAfterLast() == false) {
String id = "" + c.getInt(0);
String nama = c.getString(1);
String longitude = c.getString(3);
String latitude = c.getString(2);
String ket = c.getString(4);
Marker marker = map.addMarker(new MarkerOptions()
.position(
new LatLng(Double.parseDouble(latitude), Double
.parseDouble(longitude)))
.title(nama)
.snippet(ket)
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.icmarker)));
c.moveToNext();
}
}
I have not found on this answer , several times I run this application , fixed the error , if there is something wrong with my code ? Please help