Osmdroid blank map on some devices - android

Before marking as a duplicate, please read the question.
I am using osmbonuspack for displaying maps in my app and keep getting blank map on some devices.
Need help in solving.
Yes, I've read all similar questions and tried offered solutions.
Yes, I've added write external storage permission to the manifest (and requesting permissions runtime since Marshmallow).
Yes, I've tried to use TileSourceFactory.MAPQUESTOSM,
but it's not available anymore since July 2016.
Here is the initialisation:
mMapView = (MapView) aq.id(R.id.mapview).getView();
mMapView.setMultiTouchControls(true);
mMapView.setTileSource(TileSourceFactory.MAPNIK);
mMapController = (MapController) mMapView.getController();
mMapController.setZoom(14);
mMyLocationMarker = new MyLocationNewOverlay(getActivity(), mMapView);
mMyLocationMarker.enableFollowLocation();
mMapView.getOverlays().add(mMyLocationMarker);
Here are manifest permissions:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
Any help is appreciated

Set the user agent to your application id. See
https://github.com/osmdroid/osmdroid/issues/366
OpenStreetMapTileProviderConstants.setUserAgentValue(BuildConfig.APPLICATION_ID);

Related

React-native-image-picker doesnt open camera

I am using react-native-image-picker for my app.
const ImageChange = () => {
var options = {
title: 'Select Image',
};
ImagePicker.showImagePicker(options, response=>{
console.log('Response=', response)
if(response.didCancel){
console.log('user cancelled')
}else if(response.error){
console.log('picker error'+response.error)
}else{
let source = response
console.log(response.uri)
}
})
}
When I call the method by pressing an icon it shows me two options to take photo and choose from the gallery. But when I press "take photo" option it asks me permission for storage but not from camera. On calling the method again it shows me the options but when selecting "take photo" it shows an error that permissions weren't granted but choose from library works fine
I've also added these lines in my AndroidManifest.xml file
<uses-permission android:name="android.hardware.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
using RN>=0.60
Instead of
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
This worked for me
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-feature android:name="android.hardware.camera" />

getNeighboringCellInfo() returning null

I'm most of code used a little trying to get neighbor cells info (for the current cell info, everything works fine)
List<NeighboringCellInfo> neighborCells = telMgr.getNeighboringCellInfo();
if (neighborCells == null) {
Log.d("cells", "Neighbor cells is null");
} else {
for (NeighboringCellInfo cell : neighborCells) {
Log.d("cells", cell.getCid()+"-"+cell.getLac()+" "+(-113+cell.getRssi()*2)+"dB");
String neighboringcell= cell.getCid()+"-"+cell.getLac()+" "+(-113+cell.getRssi()*2)+"dB";
Toast.makeText(getApplicationContext(), neighboringcell, Toast.LENGTH_LONG).show();
mNeighboringcell.setText(neighboringcell);
}
}
i have used this code and give this permission
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
and i am tested Samsung 4.0 and lava 4.1
Please give me solution
Thanks
It seems that's a bug, see this:
https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=24306
and this:
Neighbouring cell information is inaccurate

Android, Google maps and changing "required" in uses-permission

I currently have this code in an app that uses Google maps:
<uses-permission android:name="com.example.app.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
I have started to wonder though, if I set all these to required="false" the app would presumbly generated a shorter "requires" list when users download the app... Is there any reason not to just set them all to not required?
Currently I do this when loading maps
private void setUpMapGoogleIfNeeded() {
if (mMapGoogle == null) {
mFragmentManager = getSupportFragmentManager();
mSupportMapFragment = (SupportMapFragment) mFragmentManager.findFragmentById(R.id.mapFragment);
mMapGoogle = mSupportMapFragment.getMap();
if (mMapGoogle != null) {
mMapGoogle.setMyLocationEnabled(SharedCode.sharedSupportsGPS(true, thisActivityContext));
}
}
Does anyone have experience with this? Are the siuttations I have not thought of where setting required = false for above menions can cause errors/exceptions in my app?
There is no android:required attribute for <uses-permission> and so it will be ignored. It will not result in "a shorter "requires" list when users download the app".

osmdroid displays an empty grid

I wanted to try out having OpenStreetMap integration by osmdroid, but I got stuck at an issue where I have no idea what is missing. The scenario is as follows:
Symptom: Map widget gets displayed but only with an empty grid.
This is in my Activity class:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapView mapView = new MapView(this, 256);
mapView.setTileSource(TileSourceFactory.MAPNIK);
mapView.setClickable(true);
mapView.setBuiltInZoomControls(true);
setContentView(mapView);
}
(I tried selecting various TileSources with seemingly no difference)
My Manifest also includes these permissions (as a child of <manifest>, after <uses-sdk>):
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
...and my emulator is otherwise connected to the internet, eg. web browsers work.
osmdroid and slf4j are in the build path. The app compiles without a problem and generates no exceptions.
What could be wrong?
Many thanks!
SOLVED: This was caused by my emulator not having an external storage to cache map tiles.
I'm pretty new to OSMdroid too but try doing this?
setContentView(R.layout.offline_map_activity);
mapView = (MapView) findViewById(R.id.openmapview);
You would also need to have offline_map_activity.xml in your res/layouts:
<LinearLayout 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"
android:orientation="vertical" >
<org.osmdroid.views.MapView
android:id="#+id/openmapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
Hope this works for you. At least this worked for my codes :)
i tink your Device has don't SD. You have change the Cache Path
OpenStreetMapTileProviderConstants.setCachePath(this.getFilesDir().getAbsolutePath());

android: NeighboringCellInfo always empty !? why?

i'm trying to get info about the neighboring cells my phone can "see" atm. so far so good. i do this like this:
telManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
//...
ArrayList<NeighboringCellInfo> neighboringCellList = (ArrayList<NeighboringCellInfo>) telManager.getNeighboringCellInfo();
unfortunately, this list turns out to be empty all the time. even in different places. i live in berlin, so i don't think it's because there is actually just the one cell available!
update:
my permissions look like this:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
I've seen several questions on the same issue but it seems like none of them got a good and deterministic solution. The most common suggestion is to make sure you have the correct permission (which I see you do in your question) and there are some that say that this only works on 2G and not 3G.
Take a look at the following similar questions. It might point you in some new directions:
getNeighboringCellInfo() returning null list
Null Issue with NeighboringCellInfo, CID and LAC
Get neighboring cell in Android returns null
getNeighboringCellInfo() is deprecated in android . You should use getAllCellInfo() and save output of that in a List and using a loop on each element of List decide which is neighbor using element.isRegistered() .
NeighboringCells have isRegistered() == false .

Categories

Resources