Android :: How To Arrange Long (time Consuming) Actions?
Feb 10, 2010
For instance, we are in SomeActivity and the activity has a button that invokes moving files from one dir to another (let's call it job).On Android things change. I know there's the AsyncTask that is probably provided to solve my case. There's even a good example of how it should be used. But since there's no guarantee of how long an Activity instance will live the AsyncTask should be cancelled on onSaveInstanceState (and restarted on onRestoreInstanceState). This means using AsyncTask there's no guarantee we are able to fully fulfill the job once started. In some cases as sending an http post request for creating a user I would not want to get in "user already exists for this login" trouble on reruning the AsyncTask. This is possible since the AsyncTask can be interrupted while the request is already sent (and the server actually is doing its job - creating a new user), but the AsyncTask is canceled before we got the response.
few weeks ago I encountered a problem. My Android SDK 1.5 emulator became very slow and CPU consuming. This happened earlier, but was irregular just removing AVDs usually helped. Few weeks ago I installed Android SDK 1.6, tried to move my dev environment there and noticed that emulator runs very slowly. I rolled back to 1.5 and noticed that the same problem is there. What's going on: - emulator startup is pretty slow; - sometimes emulator hangs on startup; - sometimes after startup is complete I see Force close/Wait dialog for some Android applications/services (Alarm clock, messaging) - applications inside the emulator run MUCH slower than they ran before, I see delays in response even in launcher, when I just switching between icons with arrow keys (at this time CPU usage according to the task manager is from 35 to 50%, i.e. one core is completely busy). - now, when I'm typing this message, emulator (clean, newly created AVD, I haven't installed nothing there, just out of the box) occupied 50% of my CPU (and 140MB of RAM). Hardware: Intel Core2Duo T7500 (2.2GHz) + 2GB RAM. OS: Vista I don't have any problems with 1.6 on Linux (Kubuntu 7.10), emulator starts quickly, responds in a flash, and seldom consumes more than 20% of CPU time (usually in case my application is working with DB).
So I wanted some DigitalClock help. I have set up a digitalclock, and here's what I want to do. Once the clock hit's a certain time, perform an action. How can I control the actions on the digital time to check for a certain time?
I need to implement a JNI which render image with 3-party native function. This function call is time consuming, it cost about 1s to return. I found during that time, even if I call the JNI within another Java thread, the whole Dalvik VM is blocked. UI is frozen. I guess that's because Dalvik doesn't implement Java thread with a native thread, so any time consuming native function call will block the whole VM. I wonder how to solve this problem. My best guess is I should create a pthread in JNI to call that 3-party native function. But I don't know how to implement this kind of JNI.
Arrange/re-arrange the shortcuts in the application tab? I know how to manage them on the home screen, but I want to move the lesser-used applications to the bottom of the app tab and the more frequently-used apps to the top. (btw...this question pertains to a Droid.
I'm in a trouble managing a spinner. I have a spinner with its adapter. I initialize the spinner with a list of values when starting my activity. Then I force the selected value to be the one used in the object that I manage.
Once the screen is initialized : When the user selects a value in the spinner, according to the selected value, I may continue (or not) to another activity for let the user choose a complementary and necessary value.
If the user "cancels" this second activity, I want to rollback the spinner to its previous selected value, and cancel some actions made in the meantime.
If the user goes to the end of the second activity, everything is fine and I want juste to refresh the spinner display with the datas selected in the second activity (I overload the getView method in the adapter to do this).
Overall, I can easily do all of this, however, when I force the selected value in the spinner at the begining of my activity, or whene returning back from the second activity by "Cancel", the change value event is catched and the second activity is triggered (the user did not click anything at all).
How would you allow the second activity to be lauched only if the change of the selected value in the spinner is due to a manual action from the user, and prevent that same second activity to be launched when the value of spinner is changed "in the code "?
I tried many solutions, as setting a boolean into the adapter that tells if the next event will be raised because of an "in the code" action.
Or also putting a boolean in the adapter that tells if the adapter has initialised itself, and I force that boolean to true on the forst change catched event.
What is the best way to set an long-term alert/reminder from an Android application? I'd like to display notification in a few weeks after current date. I believe there is no need to write a service for such task. Will AlarmManager do the trick? Or should application be started daily and performing check? After countdown was started, upcoming alert should survive upgrading application from Android Market.
So after using swype (beta) for a few weeks, I notice it getting slower, and less efficient. Not sure if odd words added by tapping out words did this. Also losing steam with certain words like our vs or. Now trying HTC IME keyboard, quite nice.
For quite a while now, people have been saying how long it takes for me to answer my phone, even though it's usually on my desk and I get there after a couple of rings.
So today I tested it out. I rang my mobile number from my landline, it connected and started ringing, but it got to about six rings before the LED on my mobile started flashing and a further two rings until it started ringing!
I'm on T-Mobile, but it seems to connect OK, just take a while to register on my phone. Obviously this isn't the end of the world, but I use my mobile for business and it doesn't make me look very good!
My Evo takes about 30 seconds to dial a number. i select a contact in my contact list, the contact highlights but does not dial for about 30 seconds. While I was typing this my phone was turned sideways for the big keyboard, I would select a letter, the letter bubble appears but the letter does not show on screen. In vertical mode the keyboard is fine.
Just wondering if it is suppose to take a little while for the app management to display apps
I have a nexus one also and did a quick comparison... both have relatively the same apps ( i keep them as synced as possible)
Now its not really an Apples to Apples Comparison as I have Froyo running on nexus but what made me raise an eyebrow was when the little Loading Indicator doesn't smoothly move while its loading. http://www.youtube.com/watch?v=4pNBkEuN4Q8
I just made the switch from Moto Droid to Samsung fascinate and can't say that I'm all that happy with my decision, No froyo, horrible artifact and color hue, 3 hour charge times, a worse benchmark than my old phone. And on top of that it appears to have terrible reception! While using this phone in the same locations that I had zero problems on the droid, I can't stay connected to 3G to save my life. Youtube and Pandora are useless because I'm not able to keep connection long enough to stream. It has also caused the browser to time out pretty regularly.
YouTube videos takes longer to load. My browser sometimes doesn't load web pages completely and the speeds are way slower then 3g... Well atleast on my end... I'm in Baltimore and 4g is very much up and running. Not ranting, its just that 4g was one of sprints selling points, jus think it could be a bit better.
When I view videos it takes a very long time to buffer and when it does it gets about 5 seconds worth then has to buffer more. Is there away for it to download it better instead of stopping every few seconds to buffer more. This way it can be smoother. There has to be some way to do it my storm that didnt have no where near as much memory played them better.
My sdcard has been taking awfully long to mount to USB. It used to be almost instantaneous like your average USB thumbdrive or external hard disk. Im on a non-rooted nexus one running froyo. Any suggestions?
I am working on building an android app but I'm nothing that my SQL operations are taking forever to complete
I have profiled the app to narrow it down to the act of moving the Cursor to the first row of the result set for a simple select query (only returning 1 row where I'm testing it to eliminate the size of the result set as a problem.
Are there any better options for moving to the start of the result set?
this runs 3 times and i have time it to approximately 2 secs for all the rest of the code or over a minute with this in.
i have also run just the rawQuery statement with out the move to first and its takes bout 18 secs so im looking at the worst part of the code first.
Trying to run WIFI TETHERING, but SU just sits there and doesn't seem to do anything, but maybe force close. Running Smash rom. Honestly, I would probably switch roms, but I don't know how to do that. Someone else rooted my phone. Also, I'd love to get rid of stock apps.
I posted a thread about my battery life earlier this week, and I thank all the for the help! Here is another issue I am having that may be related. My phone takes forever to charge. Example: used my phone heavily this morning from 5:30 am till around 9am. Came home, battery was down to 15% or so. Plugged it into the AC charger around 10am, went outside and mowed the yard, etc. Finally checked the phone around 4pm, and it was still charging. Battery was showing 90% or so. Shouldn't it fully charge in around 2 hours or less? I did some research and found some people having charging issues after they upgraded to 2.1, which I did right after I got the phone. I did check with my local RS where I got the phone, and the guy I spoke with has a Hero, and his does not do this. He suggested I go to a Sprint store and have them look at it.
With a largely white image on screen, if you tilt the phone to the left, does it take on a pinkish hue? Also, does adding a Shortcut -> Application take insanely long to load every single time? I just want to make sure I'm not the only one experiencing this.
Have any of you found that it takes a really long time to charge the phone to 100% battery? Maybe i'm coming from a sidekick and it was short to charge fully but is this true for you guys too or am i just not used to needing this long to charge a phone up?
I've noticed today that sending a picture messages takes a loong time on my Droid--considerably longer than on my old feature phone. Usually, it takes around 3-4 minutes. One picture took around 10 minutes to send. My apartment has bad reception, but when I sent these messages I had 3g and 3 reception bars. Is this normal?
My Droid Eris will charge from about 20% to 100% in a matter of 1-3 hours- it's always quite fast! Last night, my phone was at 20% when I went to sleep at about 12am and when I woke up at 6am it was only at 40%. The phone felt very hot. I took it off the charger and put it in another plug. It is now 4pm and the phone is only at 80% and at times feels hot. I checked out the cord and there are no lesions or breaks or any visible problems w/ the cord. I'm not sure what's going on- any thoughts? I'm going to take it to the VZW store to obtain an understanding. It's only been 3-4 months that I obtained the phone.
This has been an issue since the first day after I installed all my apps via appbrain (roughly 300). It takes ~36 seconds for it to open. I am starting to think I am the only one experiencing this. Does anyone have any ideas?
I recently bought a used, but in good condition Optimus V. Not a great phone, but it does what I need. However, in the past couple days I've found that when the phone does its auto-timeout, it takes up to ten seconds for it to switch back on. By that I mean that when I press the power button just to get to the passcode screen (not to turn the whole thing on), it takes much longer than it did when I first got it.
I've uninstalled recent apps, but it's done nothing. What to do?