Back to project page C2Framework.
The source code is released under:
Apache License
If you think the Android project C2Framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package gaia.c2.content.android.model; //from w w w . ja v a 2 s. c o m import android.content.Context; import android.os.Parcel; import android.os.Parcelable; import android.os.Vibrator; import gaia.c2.content.model.ContextDependentModel; import gaia.c2.context.C2Context; /** * Created by kmr on 4/21/14. */ public class Vibration implements ContextDependentModel, Parcelable { public static final String MIME_TYPE = "x-android/vibration"; private C2Context ctx; private long[] pattern; public Vibration(long[] pattern) { this.pattern = pattern; } @Override public Vibration using(C2Context ctx) { this.ctx = ctx; return this; } public void vibrate() { Vibrator vibrator = (Vibrator) this.ctx.getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(this.pattern, -1); } //region parcelable public Vibration(Parcel in) { this.pattern = in.createLongArray(); } @Override public int describeContents() { return this.hashCode(); } @Override public void writeToParcel(Parcel parcel, int i) { parcel.writeLongArray(this.pattern); } public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { public Vibration createFromParcel(Parcel in) { return new Vibration(in); } public Vibration[] newArray(int size) { return new Vibration[size]; } }; //endregion }