Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

UI events to consider in all apps

 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What UI events should I always take care of in my app? For example back button. What else should I care for?

Thanks
Imad
 
Ankit Garg
Sheriff
Posts: 9580
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think there are any universal rules as to which events you should handle. It depends a lot upon the nature of the application you are creating...
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Muhammad Imad Qureshi wrote:For example back button.

Overriding Back button may or may not be always required. It depends.
Ankit Garg wrote:I don't think there are any universal rules as to which events you should handle. It depends a lot upon the nature of the application you are creating...

Would second Ankit here.

However, there are certain "cases" that your code must be able to handle or tolerate(like screen orientation, low battery, incoming phone call etc.)
 
Muhammad Imad Qureshi
Ranch Hand
Posts: 238
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However, there are certain "cases" that your code must be able to handle or tolerate(like screen orientation, low battery, incoming phone call etc.)


My app very simple which does some calculations (lets assume its a calculator). I would like to keep my calculator running and let the user return to the screen where he/she left after taking the call. How do I implement this. Should I just do nothing and os will take care of this?

Thanks for your help
Imad
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not how the Android lifecycle works - the app may get stopped at any time if it's not visible. Any data you wish to preserve between app invocations needs to be saved in the onPause handler (possible using SharedPreferences) and then reinstated in the onStart handler.

The android.app.Activity javadocs talk about this in more detail.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic