-1

I want to develop an application with some advance features like shake feature, orientation of images, zoom in/out, scrolling, etc. For instance, the user can shake the phone in order to erase an entered text. Also, by rotating the phone clockwise or anti-clockwise, the orientation of the underlying images will change.

How would I do that?

Nicolas Kaiser
  • 1,592
  • 2
  • 13
  • 26
Laxmipriya
  • 459
  • 1
  • 5
  • 9

1 Answers1

2

For shaking:

You will need to use the phone's accelerometer sensor. You can find many examples of this if you Google (for example: Android: I want to shake it)

For rotations:

When the phone detects an orientation change, Android will destroy and recreate your application. There are lifecycle methods (see http://developer.android.com/reference/android/app/Activity.html) that are called that allow you to save and restore your application's current state. Again, if you Google: http://developer.android.com/guide/topics/resources/runtime-changes.html http://www.androidguys.com/2008/10/14/rotational-forceson-your-android-app/

Community
  • 1
  • 1
amb
  • 335
  • 2
  • 8
  • Thanks ! I have tried like http://stackoverflow.com/questions/2317428/android-i-want-to-shake-it . But it gives only Toast message for shake, but if i tried to write some code for image changing when i shaked the phone it is not possible, how can i write the code for change the image . – Laxmipriya Nov 18 '11 at 08:25
  • It works perfectly! Thanks amb ! I have added the VIBRATE permission to make it work: – Laxmipriya Nov 22 '11 at 09:01