Example usage for android.content Context VIBRATOR_SERVICE

List of usage examples for android.content Context VIBRATOR_SERVICE

Introduction

In this page you can find the example usage for android.content Context VIBRATOR_SERVICE.

Prototype

String VIBRATOR_SERVICE

To view the source code for android.content Context VIBRATOR_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.os.Vibrator for interacting with the vibration hardware.

Usage

From source file:eisene.riskspeedtools.TimerSetupFrag.java

@Override
public void onTimerFinished() {
    Vibrator v = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
    v.vibrate(1500);
}

From source file:org.protocoderrunner.apprunner.api.PDevice.java

@ProtoMethod(description = "makes the phone vibrate", example = "android.vibrate(500);")
@ProtoMethodParam(params = { "duration" })
public void vibrate(int duration) {
    Vibrator v = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
    v.vibrate(duration);/*w w w .  ja  va  2s.  c om*/
}

From source file:com.taradov.alarmme.AlarmNotification.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    getWindow().addFlags(//from   w  ww.j  a  va 2  s  . c o  m
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                    | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

    setContentView(R.layout.notification);

    mDateTime = new DateTime(this);
    mTextView = (TextView) findViewById(R.id.alarm_title_text);

    readPreferences();

    mRingtone = RingtoneManager.getRingtone(getApplicationContext(), mAlarmSound);
    if (mVibrate)
        mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

    start(getIntent());
}

From source file:com.bufarini.reminders.AlarmReceiver.java

@Override
public void onReceive(final Context context, final Intent intent) {
    final String action = intent.getAction();
    if (Log.LOGV)
        Log.v("AlarmInitReceiver \"" + action + "\"");
    final PendingResult result = goAsync();
    final WakeLock wakelock = AlarmAlertWakeLock.createPartialWakeLock(context);
    wakelock.acquire();/*  w w w  .  jav a2s  .  com*/
    AsyncHandler.post(new Runnable() {
        @Override
        public void run() {
            try {
                String alarmActionName = context.getResources().getString(R.string.intent_action_alarm);
                if (Intent.ACTION_BOOT_COMPLETED.equals(action)) {
                    SharedPreferences prefs = context.getSharedPreferences(Reminders.class.getName(),
                            Context.MODE_PRIVATE);
                    String accountName = prefs.getString(ListManager.PREF_ACCOUNT_NAME, null);
                    if (Log.LOGV)
                        Log.v("AlarmInitReceiver accountName = \"" + accountName + "\"");
                    if (accountName != null && !accountName.equals(""))
                        setReminders(context, accountName);
                } else if (alarmActionName.equals(action)) {
                    showNotification(context, intent);

                    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
                    vibrator.vibrate(VIBRATE_PATTERN, 1);
                }
                result.finish();
                if (Log.LOGV)
                    Log.v("AlarmInitReceiver finished");
            } finally {
                wakelock.release();
            }
        }
    });
}

From source file:net.noio.Reminder.NotificationService.java

private void Notify(Intent intent) {
    // Notification on drop down bar
    PendingIntent pimain = PendingIntent.getActivity(getApplicationContext(), intent.getIntExtra("id", 0),
            intent, 0);//from   w  w w.  j a  v a2  s  .c o  m
    NotificationCompat.Builder notif = new NotificationCompat.Builder(getApplicationContext());
    notif.setSmallIcon(R.drawable.ic_launcher);
    notif.setContentTitle(intent.getStringExtra("reminder"));
    notif.setContentText(intent.getStringExtra("string"));
    notif.setContentIntent(pimain);
    notif.setAutoCancel(true);

    NotificationManager notman = (NotificationManager) getApplicationContext()
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Vibrator v = (Vibrator) getApplicationContext().getSystemService(Context.VIBRATOR_SERVICE);
    v.vibrate(this.VIBRATE_TIME);
    notman.notify(intent.getIntExtra("id", 0), notif.build());
}

From source file:angeloid.dreamnarae.Boot_Script.java

@Override
public void onReceive(Context c, Intent i) {

    boot_top = c.getString(R.string.boot_top);
    boot_bottom = c.getString(R.string.boot_bottom);
    boot_ticker = c.getString(R.string.boot_tickker);

    if (!(RootTools.isAccessGiven())) {
        Toast.makeText(c, R.string.noroottoast, Toast.LENGTH_LONG).show();
    } else {/*  w w w.  j  a v  a  2  s .  c  o  m*/
        if (new File("/system/etc/dreamnarae.sh").exists()) {
            CommandCapture command = new CommandCapture(0, "mount -o rw,remount /system",
                    "sh /system/etc/dreamnarae.sh", "sh /system/etc/install-recovery.sh");

            NotificationManager manager = (NotificationManager) c
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            NotificationCompat.Builder ncbuilder = new NotificationCompat.Builder(c);
            ncbuilder.setContentTitle(boot_top);
            ncbuilder.setContentText(boot_bottom);
            ncbuilder.setSmallIcon(R.drawable.ic_launcher);
            ncbuilder.setAutoCancel(true);
            ncbuilder.setTicker(boot_ticker);
            Vibrator vibe = (Vibrator) c.getSystemService(Context.VIBRATOR_SERVICE);
            try {
                RootTools.getShell(true).add(command).waitForFinish();
                Log.d("debug", "ok!");
                vibe.vibrate(200);
                manager.notify(1, ncbuilder.build());
            } catch (InterruptedException e) {
            } catch (IOException e) {
            } catch (TimeoutException e) {
            } catch (RootDeniedException e) {
            }

        }

    }
}

From source file:com.example.android.bluetoothchat.TVremoteFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);/* w w w .j  av a  2  s .  c  om*/

    MyVib = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
}

From source file:com.dmitrybrant.android.cardboardmpo.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.common_ui);// w  w w .  j  a v  a  2s . c  o  m

    cardboardView = (CardboardView) findViewById(R.id.cardboard_view);
    cardboardView.setRestoreGLStateEnabled(false);
    cardboardView.setRenderer(this);
    setCardboardView(cardboardView);

    vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

    progressLeft = (ProgressBar) findViewById(R.id.progress_left);
    progressRight = (ProgressBar) findViewById(R.id.progress_right);
    statusLeft = (TextView) findViewById(R.id.status_text_left);
    statusRight = (TextView) findViewById(R.id.status_text_right);

    setProgress(true);
    setStatus(true, getString(R.string.status_finding_files));

    camera = new float[16];
    view = new float[16];
    modelViewProjection = new float[16];
    modelView = new float[16];
    headView = new float[16];

    checkReadPermissionThenScanImages();
}

From source file:com.manumanu.alarmexample2.AlarmNotification.java

@Override
protected void onCreate(Bundle bundle) {
    super.onCreate(bundle);

    getWindow().addFlags(/*  w ww. j a  v  a2s  .com*/
            WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                    | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

    setContentView(R.layout.notification);

    mDateTime = new DateTime(this);
    mTextView = (TextView) findViewById(R.id.alarm_title_text);
    dissmiss = (Button) findViewById(R.id.dismiss_alarm);
    dissmiss.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            stop();
        }
    });
    readPreferences();
    mRingtoneManager = new RingtoneManager(this);
    mRingtone = mRingtoneManager.getRingtone(this, Settings.System.DEFAULT_RINGTONE_URI);
    if (mVibrate)
        mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

    start(getIntent());
}

From source file:com.crs4.roodin.moduletester.activities.PositionActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_map);

    SensorManager sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

    block = this.getBlockFeatures();
    cellDimension = block.getCellDimension();

    position = new Position(sensorManager, this, block);
    position.addListener(this);

    //rotation = Rotation.getInstance();
    //rotation.initialize((SensorManager) getSystemService(SENSOR_SERVICE));
    //rotation.addListener(this);

    mapScrollView = (MapScrollView) findViewById(R.id.mapScrollView);

    customView = new CustomView(getApplicationContext());
    customView.setBlock(block);//from w  w  w.j av a2s .c  o m

    Box box = new Box(new Point(12, 12), new Point(24, 24)); //NE (row,col) alto-destra  ---   SW  (row, col) basso sinistra
    Box box2 = new Box(new Point(25, 25), new Point(32, 32)); //NW (row,col)   ---   SE  (row, col)
    boxList.add(box);
    boxList.add(box2);

    bb = new BoundingBox();
    bb.addListener(this);

    customView.setBoxList(boxList);
    customView.setMapRotation(block.getInitialRotation());

    float[] pxInitialPosition = new float[2];
    pxInitialPosition[0] = 750;
    pxInitialPosition[1] = 464;

    mapScrollView.setOnDrawListener(customView, 1000, 1000);
    mapScrollView.centerDisplayTo(pxInitialPosition[0], pxInitialPosition[1]); //center display every step
    customView.setPosition(pxInitialPosition[0], pxInitialPosition[1]);

    initialRotation = block.getInitialRotation();

    sid = position.initSession(block.getStartPos(), block.getShape(), block.getBarred(), 25);

}