Posts

Showing posts from May, 2015

Accelerometer (Shake Events) Example with Service Android.

Hello Friends, This tutorial is about get shake event when you are not in Application or any specific activity. With the help of Service we can get Shake Event out of activity. First of We will create class which extends Service and Implements SensorEventListener. 1. Class  MyService.java import android.app.Notification ; import android.app.NotificationManager ; import android.app.PendingIntent ; import android.app.Service ; import android.content.Context ; import android.content.Intent ; import android.hardware.Sensor ; import android.hardware.SensorEvent ; import android.hardware.SensorEventListener ; import android.hardware.SensorManager ; import android.os.Handler ; import android.os.IBinder ; import android.support.v4.app.NotificationCompat ; import com.ammy.shakeevent.R ; public class MyService extends Service implements SensorEventListener { private SensorManager mSensorManager ; private Sensor mAccelerometer ; private

Display Option menu(Overflow icon) icon in ActionBar in devices like Samsung S4 & Xolo.

Image
In android when we are dealing with Option menu then the worst part is that in some devices the option menu Button is invisible from action-bar like ( Samsung , XOLO devices). This is because Mobile devices has a hardware button for option menu. to solve this issue There is one tricky approach. 1. Create Class file in your application which extends Application class. 2. Override onCreate() of Application class. 3. write below code of under onCreate() try { ViewConfiguration config = ViewConfiguration . get ( this ); Field menuKeyField = ViewConfiguration . class . getDeclaredField ( "sHasPermanentMenuKey" ); if ( menuKeyField != null ) { menuKeyField . setAccessible ( true ); menuKeyField . setBoolean ( config , false ); } } catch ( Exception ex ) { ex . printStackTrace (); } 4.