Find Places Nearby in Google Maps using Google Places API - android

http://javapapers.com/android/find-places-nearby-in-google-maps-using-google-places-apiandroid-app/
This Android tutorial is to learn about using Google Places API to find places nearby in Google maps. Ones the app runs then and click the button it wont pass the googlePlacesJson values and there by it returns null.
12-14 15:06:16.266 6095-6095/com.example.tony_.test_no E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.tony_.test_no, PID: 6095
java.lang.NullPointerException
at com.example.tony_.test_no.PlacesDisplayTask.onPostExecute(PlacesDisplayTask.java:42)
at com.example.tony_.test_no.PlacesDisplayTask.onPostExecute(PlacesDisplayTask.java:18)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5867)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
at dalvik.system.NativeStart.main(Native Method)
12-14 15:06:17.938 6095-6095/com.example.tony_.test_no D/Process: killProcess, pid=6095

Please check code below
public class PlacesDisplayTask extends AsyncTask<Object, Integer, List<HashMap<String, String>>> {
JSONObject googlePlacesJson;
GoogleMap googleMap;
#Override
protected List<HashMap<String, String>> doInBackground(Object... inputObj) {
List<HashMap<String, String>> googlePlacesList = null;
Places placeJsonParser = new Places();
try {
googleMap = (GoogleMap) inputObj[0];
googlePlacesJson = new JSONObject((String) inputObj[1]);
googlePlacesList = placeJsonParser.parse(googlePlacesJson);
} catch (Exception e) {
Log.d("Exception", e.toString());
}
return googlePlacesList;
}
#Override
protected void onPostExecute(List<HashMap<String, String>> list) {
googleMap.clear();
for (int i = 0; i < list.size(); i++) {
MarkerOptions markerOptions = new MarkerOptions();
HashMap<String, String> googlePlace = list.get(i);
double lat = Double.parseDouble(googlePlace.get("lat"));
double lng = Double.parseDouble(googlePlace.get("lng"));
String placeName = googlePlace.get("place_name");
String vicinity = googlePlace.get("vicinity");
LatLng latLng = new LatLng(lat, lng);
markerOptions.position(latLng);
markerOptions.title(placeName + " : " + vicinity);
googleMap.addMarker(markerOptions);
}
}
}

Related

Can We Use nearby place search api to get Locations like "Filling Stations " etc..?

Here IS My Code example which works fine for "Schools,Restaurants" but not working for Filling stations..I think the space is the problem..
case R.id.B_restaurant:
mMap.clear();
dataTransfer = new Object[2];
String restaurant = "restaurant";
url = getUrl(latitude, longitude, restaurant);
getNearbyPlacesData = new com.example.husnainbutt.driveescuev22.**GetNearbyPlacesData();**
dataTransfer[0] = mMap;
dataTransfer[1] = url;
getNearbyPlacesData.execute(dataTransfer);
Toast.makeText(MapsActivity.this, "Showing Nearby Restaurants", Toast.LENGTH_LONG).show();
break;
And GetNearbyplaces is following below It seems to look fine but i can't figure out the problem with keyword which includes space plz help me soi can save my time ..!!
public class GetNearbyPlacesData extends AsyncTask<Object, String, String> {
String googlePlacesData;
GoogleMap mMap;
String url;
#Override
protected String doInBackground(Object... objects) {
mMap = (GoogleMap)objects[0];
url = (String)objects[1];
com.example.husnainbutt.driveescuev22.DownloadURL downloadUrl = new com.example.husnainbutt.driveescuev22.DownloadURL();
try {
googlePlacesData = downloadUrl.readUrl(url);
} catch (IOException e) {
e.printStackTrace();
}
return googlePlacesData;
}
#Override
protected void onPostExecute(String s) {
List<HashMap<String, String>> nearbyPlaceList = null;
com.example.husnainbutt.driveescuev22.DataParser parser = new com.example.husnainbutt.driveescuev22.DataParser();
nearbyPlaceList = parser.parse(s);
showNearbyPlaces(nearbyPlaceList);
}
private void showNearbyPlaces(List<HashMap<String,String>> nearbyPlaceList)
{
for(int i = 0;i<nearbyPlaceList.size() ; i++)
{
MarkerOptions markerOptions = new MarkerOptions();
HashMap<String , String> googlePlace = nearbyPlaceList.get(i);
Log.d("onPostExecute","Entered into showing locations");
String placeName = googlePlace.get("place_name");
String vicinity = googlePlace.get("vicinity");
double lat = Double.parseDouble( googlePlace.get("lat") );
double lng = Double.parseDouble( googlePlace.get("lng"));
LatLng latLng = new LatLng(lat, lng);
markerOptions.position(latLng);
markerOptions.title(placeName +" : "+ vicinity);
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
mMap.addMarker(markerOptions);
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(10));
}
}
}
You could use the Place-Types:
https://developers.google.com/places/supported_types?hl=de
Using the type "gas_station" should help.

Null Pointer Exception in AsyncTask class [duplicate]

This question already has answers here:
What is a NullPointerException, and how do I fix it?
(12 answers)
Closed 7 years ago.
I am getting a NullPointerException int the following code.For the complete program refer http://wptrafficanalyzether.in/blog/showing-nearby-places-using-google-places-api-and-google-map-android-api-v2/.
Logcat
FATAL EXCEPTION: main
Process: com.example.android.googleplaces, PID: 2813
java.lang.NullPointerException
at com.example.android.googleplaces.MainActivity$ParserTask.onPostExecute(MainActivity.java:200)
at com.example.android.googleplaces.MainActivity$ParserTask.onPostExecute(MainActivity.java:169)
and code:
class ParserTask extends AsyncTask<String, Integer, List<HashMap<String,String>>>{
JSONObject jObject;
// Invoked by execute() method of this object
#Override
protected List<HashMap<String,String>> doInBackground(String... jsonData) {
List<HashMap<String, String>> places = null;
PlaceJSONParser placeJsonParser = new PlaceJSONParser();
try{
jObject = new JSONObject(jsonData[0]);
/** Getting the parsed data as a List construct */
places = placeJsonParser.parse(jObject);
}catch(Exception e){
Log.d("Exception",e.toString());
}
return places;
}
// Executed after the complete execution of doInBackground() method
#Override
protected void onPostExecute(List<HashMap<String,String>> list){
// Clears all the existing markers
if(mGoogleMap!=null)
mGoogleMap.clear();
for(int i=0;i<list.size();i++){
// Creating a marker
MarkerOptions markerOptions = new MarkerOptions();
// Getting a place from the places list
HashMap<String, String> hmPlace = list.get(i);
// Getting latitude of the place
double lat = Double.parseDouble(hmPlace.get("lat"));
// Getting longitude of the place
double lng = Double.parseDouble(hmPlace.get("lng"));
// Getting name
String name = hmPlace.get("place_name");
// Getting vicinity
String vicinity = hmPlace.get("vicinity");
LatLng latLng = new LatLng(lat, lng);
// Setting the position for the marker
markerOptions.position(latLng);
// Setting the title for the marker.
//This will be displayed on taping the marker
markerOptions.title(name + " : " + vicinity);
// Placing a marker on the touched position
if(mGoogleMap!=null)
mGoogleMap.addMarker(markerOptions);
}
}
}
Well If its from mGoogleMap.addMarker(markerOptions); line(and you are sure that markeroptions variable is not null) it means that you are adding the marker while the map is not ready ...
you should call the asyncTask once the map is loaded as the below code :
mGoogleMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
#Override
public void onMapLoaded() {
//start async task here
}
});
Hope this will help.
Change this line
List<HashMap<String, String>> places = null;
with
List<HashMap<String, String>> places = new ArrayList<HashMap<String, String>>();
Hope it will solve your problem.

Error in get route in Maps

I try to get the route between 3 locals but always return a error, this error:
java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
at $ParserTask.onPostExecute(Mapa.java:195)
at $ParserTask.onPostExecute(Mapa.java:169)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5832)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
this is the code where I have the error:
private class ParserTask extends
AsyncTask<String, Integer, List<List<HashMap<String, String>>>> {
#Override
protected List<List<HashMap<String, String>>> doInBackground(
String... jsonData) {
JSONObject jObject;
List<List<HashMap<String, String>>> routes = null;
try {
jObject = new JSONObject(jsonData[0]);
PathJSONParser parser = new PathJSONParser();
routes = parser.parse(jObject);
} catch (Exception e) {
e.printStackTrace();
}
return routes;
}
#Override
protected void onPostExecute(List<List<HashMap<String, String>>> routes) {
ArrayList<LatLng> points = null;
PolylineOptions polyLineOptions = null;
// traversing through routes
for (int i = 0; i < routes.size(); i++) {
points = new ArrayList<LatLng>();
polyLineOptions = new PolylineOptions();
List<HashMap<String, String>> path = routes.get(i);
for (int j = 0; j < path.size(); j++) {
HashMap<String, String> point = path.get(j);
double lat = Double.parseDouble(point.get("lat"));
double lng = Double.parseDouble(point.get("lng"));
LatLng position = new LatLng(lat, lng);
points.add(position);
}
polyLineOptions.addAll(points);
polyLineOptions.width(2);
polyLineOptions.color(Color.BLUE);
}
googleMap.addPolyline(polyLineOptions);
}
}
I have 2 more classes to parse to JSON
Why have you initialised as null and in do in Background method?
List<List<HashMap<String, String>>> routes = null;
You can try removing the null declaration and put it in the class declaration and not in the Asynctask
Please have a look at this tutorial for more information.

Google Map crash on Android app

Someday the code crash...
My AndroidManifiest is correct even mi API credentials, my internet conecction works fine.
I am using Android Studio , the SDK are installed too.
Here is the Logcat
java.lang.NullPointerException: Attempt to invoke interface method 'int java.util.List.size()' on a null object reference
at info.androidhive.slidingmenu.VanWhi$ParserTask.onPostExecute(VanWhi.java:139)
at info.androidhive.slidingmenu.VanWhi$ParserTask.onPostExecute(VanWhi.java:113)
at android.os.AsyncTask.finish(AsyncTask.java:636)
at android.os.AsyncTask.access$500(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
And this is the Fragment
public class VanWhi extends FragmentActivity {
private static final LatLng VANCOUVER = new LatLng( 49.281612, -123.115464);
private static final LatLng WHISLER = new LatLng( 50.116966, -122.956546);
GoogleMap googleMap;
final String TAG = "PathGoogleMapActivity";
#TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.vanwhi);
ActionBar actionBar = getActionBar();
actionBar.setHomeButtonEnabled(true);
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
googleMap = fm.getMap();
googleMap.getUiSettings().setMyLocationButtonEnabled(true);
googleMap.getUiSettings().setCompassEnabled(true);
googleMap.setMyLocationEnabled(true);
MarkerOptions options = new MarkerOptions();
options.position(VANCOUVER);
options.position(WHISLER);
googleMap.addMarker(options);
String url = getMapsApiDirectionsUrl();
ReadTask downloadTask = new ReadTask();
downloadTask.execute(url);
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(VANCOUVER,
6));
addMarkers();
}
private String getMapsApiDirectionsUrl() {
String waypoints = "waypoints=optimize:true|"
+ "|" + "|" + VANCOUVER.latitude + ","
+ VANCOUVER.longitude + "|" + WHISLER.latitude + ","
+ WHISLER.longitude;
String sensor = "sensor=false";
String params = waypoints + "&" + sensor;
String output = "json";
String url = "https://maps.googleapis.com/maps/api/directions/"
+ output + "?" + params;
return url;
}
private void addMarkers() {
if (googleMap != null) {
googleMap.addMarker(new MarkerOptions().position(VANCOUVER)
.title("VANCOUVER"));
googleMap.addMarker(new MarkerOptions().position(WHISLER)
.title("WHISTLER"));
}
}
private class ReadTask extends AsyncTask<String, Void, String> {
#Override
protected String doInBackground(String... url) {
String data = "";
try {
HttpConnection http = new HttpConnection();
data = http.readUrl(url[0]);
} catch (Exception e) {
Log.d("Background Task", e.toString());
}
return data;
}
#Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
new ParserTask().execute(result);
}
}
private class ParserTask extends
AsyncTask<String, Integer, List<List<HashMap<String, String>>>> {
#Override
protected List<List<HashMap<String, String>>> doInBackground(
String... jsonData) {
JSONObject jObject;
List<List<HashMap<String, String>>> routes = null;
try {
jObject = new JSONObject(jsonData[0]);
PathJSONParser parser = new PathJSONParser();
routes = parser.parse(jObject);
} catch (Exception e) {
e.printStackTrace();
}
return routes;
}
#Override
protected void onPostExecute(List<List<HashMap<String, String>>> routes) {
ArrayList<LatLng> points = null;
PolylineOptions polyLineOptions = null;
// traversing through routes
for (int i = 0; i < routes.size(); i++) {
points = new ArrayList<LatLng>();
polyLineOptions = new PolylineOptions();
List<HashMap<String, String>> path = routes.get(i);
for (int j = 0; j < path.size(); j++) {
HashMap<String, String> point = path.get(j);
double lat = Double.parseDouble(point.get("lat"));
double lng = Double.parseDouble(point.get("lng"));
LatLng position = new LatLng(lat, lng);
points.add(position);
}
polyLineOptions.addAll(points);
polyLineOptions.width(8);
polyLineOptions.color(Color.BLUE);
}
googleMap.addPolyline(polyLineOptions);
}
}
}
It is from info.androidhive.slidingmenu and not from the Fragment you sent.
It's a nullpointer exception from a null List<>
you don't check if routes != null and path != null before your loops, maybe the json deserialisation failed, so those lists are nul

NullPointerException on GoogleMaps v2

Updating to API 19 was really annoying. I really had a hard time figuring out on how to deal with the google play services. However, when I run it, this error shows to me.
11-11 04:25:27.214: E/AndroidRuntime(1340): java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.synergy88studios.quezoncityguide/com.synergy88studios.quezoncityguide.QuezonCityMap}: java.lang.NullPointerException
The logcat points to this line in my class:
map.getUiSettings().setCompassEnabled(true);
I don't know what is probably wrong here.
Here is my class:
public class QuezonCityMap extends FragmentActivity {
final Context context = this;
Button routes;
double latitude = 14.635576;
double longitude = 121.033115;
LatLng latlng = new LatLng(14.6353475, 121.0327501);
LatLngBounds QC = new LatLngBounds(
new LatLng(14.656669, 120.998598), new LatLng(14.666965, 121.098934));
MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)).title("Shell").snippet("Sa tabi ng Estuar Building");
Marker mark;
GoogleMap map;
ArrayList<LatLng> markerPoints;
TextView tvDistanceDuration;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quezon_city_map);
tvDistanceDuration = (TextView) findViewById(R.id.tv_distance_time);
// Initializing
markerPoints = new ArrayList<LatLng>();
// Getting reference to SupportMapFragment of the activity_main
SupportMapFragment fm = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
// Getting Map for the SupportMapFragment
map = fm.getMap();
// Set Compass Enabled
map.getUiSettings().setCompassEnabled(true);
map.getUiSettings().setRotateGesturesEnabled(true);
// create marker
// Changing marker icon
marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.share));
map.moveCamera(CameraUpdateFactory.newLatLngZoom(QC.getCenter(), 12));
// Enable MyLocation Button in the Map
map.setMyLocationEnabled(true);
mark = map.addMarker(marker);
//button
map.setOnCameraChangeListener(new OnCameraChangeListener() {
#Override
public void onCameraChange(CameraPosition arg0) {
// adding marker
if(arg0.zoom <16){
mark.setVisible(false);}
else
mark.setVisible(true);
if(arg0.zoom > 17){
mark.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.share));
}
}
});
// Setting onclick event listener for the map
map.setOnMapClickListener(new OnMapClickListener() {
#Override
public void onMapClick(LatLng point) {
// Already two locations
if(markerPoints.size()>1){
markerPoints.clear();
map.clear();
MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)).title("Shell").snippet("Sa tabi ng Estuar Building");
// Changing marker icon
marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.share));
// adding marker
map.addMarker(marker);
}
// Adding new item to the ArrayList
markerPoints.add(point);
// Creating MarkerOptions
MarkerOptions options = new MarkerOptions();
// Setting the position of the marker
options.position(point);
/**
* For the start location, the color of marker is GREEN and
* for the end location, the color of marker is RED.
*/
if(markerPoints.size()==1){
options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
}else if(markerPoints.size()==2){
options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED));
}
// Add new marker to the Google Map Android API V2
map.addMarker(options);
// Checks, whether start and end locations are captured
if(markerPoints.size() >= 2){
LatLng origin = markerPoints.get(0);
LatLng dest = markerPoints.get(1);
// Getting URL to the Google Directions API
String url = getDirectionsUrl(origin, dest);
DownloadTask downloadTask = new DownloadTask();
// Start downloading json data from Google Directions API
downloadTask.execute(url);
}
}
});
}
private String getDirectionsUrl(LatLng origin,LatLng dest){
// Origin of route
String str_origin = "origin="+origin.latitude+","+origin.longitude;
// Destination of route
String str_dest = "destination="+dest.latitude+","+dest.longitude;
// Sensor enabled
String sensor = "sensor=false";
// Building the parameters to the web service
String parameters = str_origin+"&"+str_dest+"&"+sensor;
// Output format
String output = "json";
// Building the url to the web service
String url = "https://maps.googleapis.com/maps/api/directions/"+output+"?"+parameters;
return url;
}
/** A method to download json data from url */
private String downloadUrl(String strUrl) throws IOException{
String data = "";
InputStream iStream = null;
HttpURLConnection urlConnection = null;
try{
URL url = new URL(strUrl);
// Creating an http connection to communicate with url
urlConnection = (HttpURLConnection) url.openConnection();
// Connecting to url
urlConnection.connect();
// Reading data from url
iStream = urlConnection.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(iStream));
StringBuffer sb = new StringBuffer();
String line = "";
while( ( line = br.readLine()) != null){
sb.append(line);
}
data = sb.toString();
br.close();
}catch(Exception e){
Log.d("Exception while downloading url", e.toString());
}finally{
iStream.close();
urlConnection.disconnect();
}
return data;
}
// Fetches data from url passed
private class DownloadTask extends AsyncTask<String, Void, String>{
// Downloading data in non-ui thread
#Override
protected String doInBackground(String... url) {
// For storing data from web service
String data = "";
try{
// Fetching the data from web service
data = downloadUrl(url[0]);
}catch(Exception e){
Log.d("Background Task",e.toString());
}
return data;
}
// Executes in UI thread, after the execution of
// doInBackground()
#Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
ParserTask parserTask = new ParserTask();
// Invokes the thread for parsing the JSON data
parserTask.execute(result);
}
}
/** A class to parse the Google Places in JSON format */
private class ParserTask extends AsyncTask<String, Integer, List<List<HashMap<String,String>>> >{
// Parsing the data in non-ui thread
#Override
protected List<List<HashMap<String, String>>> doInBackground(String... jsonData) {
JSONObject jObject;
List<List<HashMap<String, String>>> routes = null;
try{
jObject = new JSONObject(jsonData[0]);
DirectionsJSONParser parser = new DirectionsJSONParser();
// Starts parsing data
routes = parser.parse(jObject);
}catch(Exception e){
e.printStackTrace();
}
return routes;
}
// Executes in UI thread, after the parsing process
#Override
protected void onPostExecute(List<List<HashMap<String, String>>> result) {
ArrayList<LatLng> points = null;
PolylineOptions lineOptions = null;
MarkerOptions markerOptions = new MarkerOptions();
String distance = "";
String duration = "";
if(result.size()<1){
Toast.makeText(getBaseContext(), "No Points", Toast.LENGTH_SHORT).show();
return;
}
// Traversing through all the routes
for(int i=0;i<result.size();i++){
points = new ArrayList<LatLng>();
lineOptions = new PolylineOptions();
// Fetching i-th route
List<HashMap<String, String>> path = result.get(i);
// Fetching all the points in i-th route
for(int j=0;j<path.size();j++){
HashMap<String,String> point = path.get(j);
if(j==0){ // Get distance from the list
distance = (String)point.get("distance");
continue;
}else if(j==1){ // Get duration from the list
duration = (String)point.get("duration");
continue;
}
double lat = Double.parseDouble(point.get("lat"));
double lng = Double.parseDouble(point.get("lng"));
LatLng position = new LatLng(lat, lng);
points.add(position);
}
// Adding all the points in the route to LineOptions
lineOptions.addAll(points);
lineOptions.width(2);
lineOptions.color(Color.RED);
}
tvDistanceDuration.setText("Distance:"+distance + ", Duration:"+duration);
// Drawing polyline in the Google Map for the i-th route
map.addPolyline(lineOptions);
}
}
I can't find what could be null here. There is no error in the class. Can please someone help me? Thanks. Here is my logcat:
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.synergy88studios.quezoncityguide/com.synergy88studios.quezoncityguide.QuezonCityMap}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.synergy88studios.quezoncityguide.QuezonCityMap.onCreate(QuezonCityMap.java:83)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
... 11 more
My XML
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".QuezonCityMap" >
<TextView
android:id="#+id/tv_distance_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world"
android:layout_alignParentTop="true" />
<fragment
android:id="#+id/map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/tv_distance_time"
class="com.google.android.gms.maps.SupportMapFragment"
android:name="com.google.android.gms.maps.SupportMapFragment"
/>
<Button
android:id="#+id/buttonRoutes"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/map"
android:layout_alignParentLeft="true"
android:layout_marginTop="7dp"
android:layout_marginLeft="9dp"
/>

Categories

Resources