Mapbox download offline maps on click - android

I am using MapBox on my app and I have a fragment which is separate from the activity that has the map.
In that fragment I have a ListView, which contains a list of region names.
I want to create the option to click on the ListView and generate a download of that region.
I have looked at this guide: https://www.mapbox.com/android-docs/map-sdk/overview/offline/
but that refers to downloading a specific region when activity starts.
How do I connect my ListView items with the option to download specific regions?
I have already created the LatLngBounds, metadata and OfflineTilePyramidRegionDefinition of the regions I need.
Thanks!

Are you specifically speaking about downloading a region without actually showing the map? I'd recommend trying out the Offline Plugin #tobrun has been working on. It runs the download in the background inside a service which will allow your users to leave the app and continue downloading the region.

Related

creating android text-based game

I am thinking about creating a text-based game (similar to gamebooks) for android device. In this moment only theoretically. Do you have some advice please, which way to go?
You probably know how gamebooks works, but the gamebook I want, will be very easy, should work like this:
User has shown some image, text and 3 options (questions), he decides which option to click, then a new page is showing (according to the clicked option) with another image, text and another 3 options. Then again, the user clicks one option, another page opens, etc.
My question is not how to do it programmatically, but how to start with this in Android Studio, what system to use for such game on android or which way to go.
Because I think it has no sense to create intents after each click, as there might be hundreds of clickable options.
I have already created such game on my website with php/html/js, but I want to create it also offline for android.
Intents implies one activity per page - unmaintainable.
You should work with a database and load based on user interaction. So you'll need to learn about Databases and Asynchronicity (working in the background while updating the UI so the user knows)

Displaying Google Map within service using window manager system service

In my app I need to be able to display google map as overlay up on other applications.
For doing so I am using service and window manager to show google map view as TYPE_SYSTEM_ALERT .
I am already able to the display the map twice inside the activity using 2 different google API clients with same valid API key.
I can't figure it out but for some reason when attaching the 'View' which contains 'SupportMapFragment' to 'WindowManager' the map wont display , only google logo at the bottom .
I was thinking maybe it has to do something with pixel format ?
Any suggestions ?
It has to do something with kind of views which window manager supporting , maybe window manager cannot display fragments ?
Is it possible to archive what am I trying to ?
There is no problem in the implementation so I don't past code here .
maybe window manager cannot display fragments ?
Correct. Use MapView directly. It may not work especially well in your case, as not everything is designed to go in an alert window, but it is the only chance that you have.
Also note that your app may have problems starting with Android O, as Google slowly starts to rein in apps that do these sorts of overlays.

Design of list view lazy loading images component

I have a scenario which I think is pretty common in Android applications. I know partial attempts of solving the issue were made, but until now I have not stumbled upon the full implementation. I intend to try to implement such component and open source it afterwards, but I need your help in its design.
So basically my case is the following: I have list view showing image loaded from the web and text per each row. I want to lazily load the images, placing default for each image and substituting it with the real one only when the image is downloaded. I also want to keep image cache avoiding the need to download the images multiple times in short period.
Up to now I have found several implementations that are partially working including:
Tom van Zummeren's implementation of similar component with several well known problems
Jeremy Wadsack's refinement of the concept, which is more or less working
Lazy drawables source forge project.
I also saw several stackoverflow questions regarding the problem: 1, 2, 3
However I have one more requirement which makes my task a bit more complex: I allow the user of my application to affiliate himself with some of the images. I want to load the new images associated to the user whenever the user navigates to the home screen. From it he should be able to go see his images, even before they have all been downloaded and in this case again default placeholders should be visible (Note the cross screen transition). Such use cases are:
An app listing user's youtube videos
An app for facebook - consider the images of friends
An app serving news that supports user's favorites etc
Note that I want to start fetching the new data related to the user on the home screen to provide better user experience. I will keep the user-related data stored locally forever.
The question
So my basic question is what approach should I use for the implementation of the image downloading? I know that the Android manuals say Service should be used only when I want to execute task even when application is not running. On the other side I will start the image downloading on the home screen and link the downloads to UI elements just when the user navigates to the new screen (Activity) - user-related list view and I do not know how to achieve that with AsyncTask (not that I have a very precise idea how to do it with Service either).
Any suggestion will be greatly appreciated, including links.
Universal Image Downloader is a good library which helps you to do image downloading in background with your settings.
It has so many features that you can implement at your own way.

Extend my android app in different APK

I am developing an application that should be extendable
I want the user to install the base app and then extend it by installing extension packs (different APKs) or plug-ins (like go launcher and theme-packs or add-on widgets)
The only thing I could find is using library project to share the code but that doesn't fit my needs. Can someone explain how its done?
[edit]
To be more specific, here is what I want to do:
I have a set of animated scenes, effects and transitions
animated scene is a combination of code and resources
The user can select the 1st scene, 2nd scene etc..
I wish to be able to add more scenes but I don't want to include them all in one APK
I want to let the user download scenes of his choice.
To build this type of interaction, ContentProvider will be your friend. There are two options I can think of to build this type of system, depending on which direction you would like information to flow.
Option 1: Single ContentProvider in main application
Define a ContentProvider in your main application, which creates an external interface for other applications to read/write data to a common location. This provider maintains access to the scene data files/database your application needs.
Each subsequent plugin application accesses the main ContentProvider (and also warns the user if they run a plugin but haven't installed the main app yet) and installs its specific content by writing it to the ContentProvider. In this way, each plugin is designed to act as an "installer", meaning the user has to download and run the plugin from Market to install the scene content.
Option 2: Each "Plugin" application has its own ContentProvider
This option is the reverse of the above. Define a ContentProvider with a consistent interface in each plugin application and have a method from the main application that scans the system for new plugins (this can be done via PackageManager) and reads the data from each provider into its main local store.
The difference here is that the user won't have to run each plugin package, because the main application will take care of getting the data. However, there's more complexity in defining multiple providers. For instance, you have to make sure that, even if each provider has the same basic interface, they cannot have a single common authority, so you will have to scan the system for package names like your own and resolve the providers based on that information.
Editorial
Having said that, I feel I should mention that I don't believe this is a good method of providing content to your users. My personal feeling on the subject is this method pollutes the user's devices with application icons that do them no good, and it's difficult to hide that kind of thing on the mobile device. A simpler, and much cleaner approach to this would be to store your "add-on" content on a server (AWS services like S3 and SimpleDB are practically free) and use a service like Google's In-App Billing to let your users purchase the new content and download it directly into the single application rather than having them go back to Market and purchase more apps.
Hope that Helps!
I have a set of animated scenes, effects and transitions animated scene is a combination of code and resources The user can select the 1st scene, 2nd scene etc..
If the "animated scenes" are activities. your add-on APKs simply publish their own sets of activities, and you use PackageManager to determine which of your plugins are installed and how to use them.

Android Development-cannot download an image outside of onCreate

I'm new to android development and I am stuck with a problem.
I am trying to develop an android application that shows the user the location of atms, hotels etc on a google map. I haven't started working on the gps yet. As of now the app works something like this, first of all a map loads on which I intend to show the users current location. On clicking on the menu button there are 3 options:
services
about us
quit
On selecting services option the following options are available.
atm
hospital
hotel
etc
on selecting the atm option we will be shown a screen displaying some text.
on using the menu for this screen we get the following menu items.
sbi
canara
hdfc
icici
etc
my intention is that when the user selects the sbi option a map should load showing the various places where there are sbi atms near where the user is currently.
I started out with the google map api but I had to quit because when I select one of the menu options, such as "sbi", the map does not load, instead I am getting the error "application failed to load". Basically I was trying to load a map activity from my first map activity. After googling a bit without any results I tried another approach. I tried to download and view the static map of the location I wanted. It worked, but when I tried to download the static map when I select an option like before I get the same error. "application failed to load". then I tried downloading 2 images from inside onCreate that worked. I cannot do the same thing outside the onCreate. for eg.inside the function for the selected option.
I have given the link to my code below.
If someone can please look into this it would be of great help to me. I have been sitting with this problem for days now. And its urgent too. I have done the project in eclipse.
httpDownload.java --- http://dpaste.com/195981/
I looked at your code.
I think the problem is that you didn't do setContentView before loading the map outside OnCreate.

Categories

Resources