New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does the property setUseDataConnection(false) work like intented? #1691
Comments
Hi @WRPSoft, I'm glad you enjoy osmdroid! My remarks:
|
Thanks for your feedback.
This could have been a good option for on the go, e.g. if you want to prevent mobile data usage on-the-fly within the OSMDroid library, but cannot disable mobile data connection for the phone. But if it doesn't work that way, that's the way to go :) Using fixed data is of course an option.
By the way going to use flutter is not an option, cause there is this old developer wisdom: If you never dare to jump into the deep and cold water, then you will probably not be able to achieve things you want to master :) So doing it the hard way and learning Android Java is okay; programming is kind of my daily business, but at the moment I'm still struggling against Google's 'deprecated' orgy (just joking :) ) and have to get used with the GUI and workspace of Android Studio (like most of us when making their first steps in the Android world). So the Android debugging is still a little be hard for me. But that should be doable with the time :) Again, thanks for your feedback and thanks for the good work! |
@WRPSoft The SQLite tile cache is there to prevent useless mobile data usage, and it's automatic. If you already have the tile in the database and if it's not expired (it will depend on the tile provider: one week old?), there won't be internet access. If your goal is to learn Android dev, learn Android dev. |
Hi @monsieurtanuki, Developer are kind of big kids: we will again and again put our hands on the hot stove (= learning things the hard way :) ( I'm aware how the tile (caching) system is working. Downloading an offline map beforehand is of course the most smart thing to do, but sometimes the data that has already been cached is sufficient. Anyway, I have now overwritten the MapTileProviderBase and MapTileDownloader class and take into account the UsesDataConnection property, which has been always set to true in the super class. Perhaps this is not exactly what OSMDroid is designed to work, but it helps me in my special use case and it seems to work (at least yesterday's sleepless night while I did this approach :) (. Again, the OSMDroid Library is a real treasure chest. Thank you all for this great library! |
If I sum up:
It would make sense to share this code with us, because you're not the only one with that need I guess. I don't know how you did that, but I guess I would have done it that way:
@WRPSoft What do you think of that? |
Hi @monsieurtanuki, I will be happy to post my small adjustments. Now it's weekend and I must do some 'work' with my family away from the PC :), but I will be back tomorrow and post the adjustments. If it is a suggestion to others, I would be happy. I'm sure one can improve that because I'm done the changes at a late night session when I was looking for a possibe 'interface' for this specific case. PS: The main reason for this special use case is the fact that I'm using a prepaid tariff on my mobile phone and the mobile data usage is therefore somewhat limited. Probably not the common use case, but a kind of stopp switch is sometimes not that bad :) |
Hi @monsieurtanuki and OSDMDroid community Here is what I did to bring a new 'blocking switcher' into the game. By the way, this graddle thing is like a book with seven seals to me, so I've just looking in a quick way for an 'interface' to interfere some special handling without changing too much. Therefore at least I had to modify two classes (please take a look for comments called 'RW:' within the two classes at the attached zip file).
I implemented a new static (!) boolean for blocking the download. Basically it's just this if clause at the MapTileDownloader class that that is doing the trick: @OverRide
As I've seen OSMDroid is able to build a tile request chain -> I've never checked for any side effects, maybe there could be any unwanted side effects! Now our activity is taking the role:
// NOTE: doing the configuration stuff in the onCreate event as suggested
Please note: I've been working in the software development for over 20 years, but I've always been able to avoid going too deep to Java. And finally: the way OSMDroid is handling the map tiles is absolutey fine! My use case is very, very specific -> therefore please do not misunderstand this modification. It's for my internal usage, but of course, feel free to use it or better to improve. PS: If a short sample project is needed I can make that. But I don't know if it's needed and maybe nobody will use this specific approach :). PPS: Working with OSMDroid is so much fun, again, thanks for this great library! |
Addendum: I have now been able to find a side effect. It looks like after my changes the copyright overlay has to be assigned explicitly. So be sure to add this code in the map initialization, otherwise you will no longer see the copyright notice: String copyrightNotice = map.getTileProvider().getTileSource().getCopyrightNotice(); Otherwise, I haven't found any problems with my internal test version (but that doesn't mean anything) |
Hello @WRPSoft! My comments:
|
Hello OSMDroid community,
First of all: OSMDroid is an awesome library. Thanks so much for sharing this treasure box to the community!
Now a first question I couldn't get answer myself although I've read the docs.:
Does the property setUseDataConnection(false) work like intented?
I would have thought that deactivating this property would result in no more tiles being downloaded online.
But regardless of whether I assign this property with false or true, it looks like tiles are still being downloaded over the network. I would like to implement a real offline mode for on the go, which means that only cached tiles are displayed or the map view remains empty if there aren't any tiles cached.
I'm a Windows developer, just making my first steps into Android. Therefore debugging the OSMDroid code is still a bit cumbersome for me at the moment. But I hopefully will get better :)
I'm using OSMDroid for a small and really lightweight free GPS viewer (TCX/GPX/KMZ imports) if this does matter...
Would be nice if one could explain how setUseDataConnection(false) is intented to work.
Regards Ralph
Issue Type
[X] Question
[ ] Bug
[ ] Improvement
[ ] Build system related
[ ] Performance
[ ] Documentation
Description and/or steps/code to reproduce the problem
Just setting
map.setUseDataConnection(false);
It seems that tiles will still be downloaded, maybe a little but slower compared to map.setUseDataConnection(true);
Environment
If it's a bug, version(s) of android this affects:
All
Version of osmdroid the issue relates to:
6.1.10
The text was updated successfully, but these errors were encountered: