开发者

Android stutter on activity change

I've got an android logging into my web service asynchronously, but when the t开发者_如何学Goask is complete, and I switch to the next activity, there is a stutter. This is annoying as there is a progress bar (in circle mode) on my activity and it pauses, restarts and then the activity is closed. This doesn't look all too good.

Here is the code:

//Create the new intent.    
Intent i = new Intent();
//Set the intent to open the pin entry screen
i.setClassName("com.visualdenim.passpad", "com.visualdenim.passpad.Pin");                           
Bundle bun = new Bundle();
//Set the data to go in the bundle
bun.putString("login_info", args[0]);
//Put the extras into the bundle
i.putExtras(bun);
//Start the credentials list activity
startActivity(i);
//Set the pretty animation
overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
//Close this activity (so the user can't access the login screen once they are logged in)
finish();

I'm wondering; does all this need to excecute on the UI thread, Is there any way of speeding all that up, or can I stop the progress bar spinning to avoid it starting again?

Thanks, I will tick the right answer!


put whatever you are doing inside an Async Task and put the dismissal of the progress dialog in the onPostExecute method of the class. This stutter happens when you try and handle inter thread communication or when there is too much load on one thread(over here that is you UI thread). With Async Task, all the thread maintenance is handled by the OS giving optimal results.


I got around the problem by fading the progress bar out, and then starting the new activity. This way, the user doesn't see the stutter on the progress bar and so the transition appears smooth.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜