java code:
package com.example.nearest_masjid;
public class GetNearByPlaces extends AsyncTask<Object,String,String>
{
private String GooglePlaceData, url;
GoogleMap mMap;
@Override
protected String doInBackground(Object... objects) {
mMap = (GoogleMap)objects[0];
url = (String)objects[1];
DownloadUrl downloadUrl = new DownloadUrl();
try
{
GooglePlaceData = downloadUrl.ReadTheUrl(url);
}
catch (IOException e) {
e.printStackTrace();
}
return GooglePlaceData;
}
Obviously, the issue here that you are passing a String as the first param, the method implementation expects Object of type GoogleMap. So check the calling method and make sure the params are in the right order.
Apart from that you need to make your code type safe. I would define a POJO and pass that as the param instead.
class MyData {
String url;
GoogleMap map;
//define getters and setters
.....
}
public class GetNearByPlaces extends AsyncTask<MyData,String,String>
{
private String GooglePlaceData, url;
GoogleMap mMap;
@Override
protected String doInBackground(MyData... data) {
mMap = data[0].getMap();
url = data[0].getUrl();
DownloadUrl downloadUrl = new DownloadUrl();
......
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.