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 "appli开发者_运维问答cation 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.
精彩评论