Ejemplo n.º 1
0
  public void sendTagWear(View v) {
    Vibrator va = (Vibrator) getSystemService(VIBRATOR_SERVICE);
    va.vibrate(1000);
    try {
      Thread.sleep(500);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    va.vibrate(1000);
    Toast.makeText(getApplicationContext(), "Tagged!", Toast.LENGTH_SHORT).show();

    new HttpAsyncTask().execute("http://10.5.5.9/gp/gpControl/command/shutter?p=0");
    // MainActivity.sendTagWear();
  }
 @Override
 public void onReceive(Context context, Intent intent) {
   Toast.makeText(context, "Don't panik but your time is up!!!!.", Toast.LENGTH_LONG).show();
   // Vibrate the mobile phone
   Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
   vibrator.vibrate(2000);
 }
Ejemplo n.º 3
0
  /**
   * @brief rateUS method
   * @param v
   * @detail This method is called when the rateUs button is clicked this calls another method
   *     launchmarket which handles the call and contains the app's market link
   */
  public void rateUS(View v) {
    final Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(vibr);

    final AlertDialog.Builder alertbox = new AlertDialog.Builder(CaptureActivity.this);

    alertbox.setMessage(R.string.rate_us_text); // Message to be displayed

    alertbox.setPositiveButton(
        R.string.yes_btn,
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            launchMarket();
          }
        });

    alertbox.setNegativeButton(
        R.string.no_btn,
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {}
        });

    // show the alert box will be swapped by other code later
    alertbox.show();
  }
Ejemplo n.º 4
0
  // send notification to Notification bar, open notification bar, will stay there,
  // but if any press, will clear all facebook notifications
  private void sendNotification(String title, String content) {
    WakeLock wl =
        pownermMgr.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "SCREEN_BRIGHT_WAKE_LOCK");
    wl.acquire(10 * 1000);

    if (orm.getNotificationVibrate()) {
      final Vibrator vib =
          (android.os.Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
      vib.vibrate(2 * 1000);
    }

    Notification notification = new Notification();
    notification.flags |= Notification.FLAG_SHOW_LIGHTS;
    notification.flags |= Notification.DEFAULT_SOUND;
    notification.ledARGB = 0xff00ff00;
    notification.ledOnMS = 500;
    notification.ledOffMS = 2000;

    if (orm.getNotificationVibrate()) {
      notification.defaults |= Notification.DEFAULT_VIBRATE;
    }

    notification.defaults |= Notification.DEFAULT_SOUND;
    notify.notifyNotifications(
        title,
        content,
        R.drawable.facebook_logo,
        Notification.FLAG_AUTO_CANCEL | Notification.FLAG_ONLY_ALERT_ONCE,
        notification);
  }
Ejemplo n.º 5
0
  @Override
  public void onSensorChanged(SensorEvent event) {
    // TODO Auto-generated method stub
    float[] values = event.values;
    float x = values[0];
    float y = values[1];
    float z = values[2];

    Log.i("uri", "x轴方向的重力加速度" + x + ";y轴方向的重力加速度" + y + ";z轴方向的重力加速度" + z);
    // 一般在这三个方向的重力加速度达到40就达到了摇晃手机的状态。
    int medumValue = 18;
    if (Math.abs(x) > medumValue || Math.abs(y) > medumValue || Math.abs(z) > medumValue) {
      id_text.setText("屌丝男士");
      try {
        player.start();
        player.setOnCompletionListener(
            new OnCompletionListener() {

              @Override
              public void onCompletion(MediaPlayer mp) {
                // TODO Auto-generated method stub
                player.pause();
                player.seekTo(0);
              }
            });
      } catch (Exception e) {
        e.printStackTrace();
      }
      vibrator.vibrate(500);
      Message msg = new Message();
      msg.what = SENSOR_SHAKE;
      handler.sendMessage(msg);
    }
  }
Ejemplo n.º 6
0
  public void decreaseCount(View view) {

    vib.vibrate(50);

    View listRow = (View) view.getTag();
    TextView counter = (TextView) listRow.findViewById(R.id.drink_count);

    String title = (String) ((TextView) listRow.findViewById(R.id.beverage_name)).getText();

    int position = 0;

    for (int j = 0; j < globalState.beverages.length; j++)
      if (globalState.beverages[j].name.compareTo(title) == 0) {
        position = j;
        break;
      }
    if (globalState.beverages[position].count == 0) return;

    globalState.beverages[position].count--;
    counter.setText("" + globalState.beverages[position].count);

    otherData
        .edit()
        .putInt(("itemCount" + position), globalState.beverages[position].count)
        .commit();
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    long[] pattern = {0, 100, 1000};
    v.vibrate(pattern, 0);

    fromUsername = intent.getStringExtra(HomeActivity.FROM_USERNAME);
    signaller = Signaller.incomingChatSignaller;
    signaller.setObserver(this);
    setContentView(R.layout.activity_incoming_call);
    Resources res = getResources();
    String text = String.format(res.getString(R.string.from_username_calling_text), fromUsername);
    TextView fromUsernameText = (TextView) findViewById(R.id.fromUsernameCallingText);
    fromUsernameText.setText(text);

    findViewById(R.id.acceptButton)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                findViewById(R.id.acceptButton).setEnabled(false);
                findViewById(R.id.declineButton).setEnabled(false);
                v.cancel();
                openChatDisplayActivity(fromUsername);
                answered = true;
                finish();
              }
            });

    findViewById(R.id.declineButton)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                findViewById(R.id.acceptButton).setEnabled(false);
                findViewById(R.id.declineButton).setEnabled(false);
                v.cancel();
                signaller.sendInitialChatAnswer(ChatStatus.DECLINED);
                answered = true;
                finish();
              }
            });

    Timer t = new Timer();
    t.schedule(
        new TimerTask() {
          @Override
          public void run() {
            if (!answered) {
              findViewById(R.id.acceptButton).setEnabled(false);
              findViewById(R.id.declineButton).setEnabled(false);
              v.cancel();
              signaller.sendInitialChatAnswer(ChatStatus.DECLINED);
              finish();
            }
          }
        },
        17500);
  }
  /**
   * 开始震动
   *
   * @param editTexts
   */
  public void shake(EditText... editTexts) {
    for (EditText editText : editTexts) {
      editText.startAnimation(shakeAnimation);
    }

    shakeVibrator.vibrate(new long[] {0, 500}, -1);
  }
Ejemplo n.º 9
0
 @Override
 public void onCardboardTrigger() {
   float[] e = new float[16];
   mHeadTransform.getEulerAngles(e, 10);
   Log.d("natalia", "cardboard trig " + String.valueOf(e[0]));
   mVibrator.vibrate(50);
 }
Ejemplo n.º 10
0
 public void removeAt(final View view, final int position) {
   // No cambia de color
   view.setBackgroundColor(fragment.getResources().getColor(R.color.colorDarkGrey));
   Vibrator v = (Vibrator) fragment.getContext().getSystemService(Context.VIBRATOR_SERVICE);
   // Vibrate for 500 milliseconds
   v.vibrate(50);
   new AlertDialog.Builder(fragment.getContext())
       .setMessage("Sure you want to delete?")
       .setNegativeButton(
           "No",
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int which) {
               dialog.dismiss();
               view.setBackgroundColor(fragment.getResources().getColor(R.color.windowBackground));
             }
           })
       .setPositiveButton(
           "Yes",
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int which) {
               dialog.dismiss();
               SQL sql = new SQL(fragment.getContext());
               fragment.list.remove(position);
               sql.resetScore(users.get(position).getEmail(), fragment.getSizeName());
               users.remove(position);
               notifyItemRemoved(position);
               notifyItemRangeChanged(position, users.size());
               if (position == 0) fragment.updateTopCard();
             }
           })
       .setIcon(android.R.drawable.ic_dialog_alert)
       .show();
 }
Ejemplo n.º 11
0
  public void sendNotifWear(View view) {

    Vibrator va = (Vibrator) getSystemService(VIBRATOR_SERVICE);
    va.vibrate(600);
    // Intent intentTwo = new Intent(this, MainActivity.class);
    // startActivity(intentTwo);
  }
Ejemplo n.º 12
0
  public void vibrate(int duration) {

    Context ctx = AndroidMeApp.getContext();
    Vibrator vibrator = (Vibrator) ctx.getSystemService(Activity.VIBRATOR_SERVICE);

    vibrator.vibrate(duration);
  }
Ejemplo n.º 13
0
 /** {@inheritDoc} */
 @Override
 public boolean onLongClick(View v) {
   if (mResizeFrame != null && selectTarget(v)) {
     mVibrator.vibrate(300);
   }
   return true;
 }
Ejemplo n.º 14
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    listView = (ListView) findViewById(R.id.listView);
    listView.setOverScrollMode(View.OVER_SCROLL_NEVER);
    dataList = new ArrayList<ItemBean>();
    t1 = (TextView) findViewById(R.id.textView1);

    vibrator = (Vibrator) getSystemService(Service.VIBRATOR_SERVICE);
    vibrator.vibrate(50);

    m1 = (ImageView) findViewById(R.id.imageView1);
    for (int i = 0; i < max * 3; i++) {
      top = 32;
      if (i == top + 2 || i == top + max + 2) {
        dataList.add(new ItemBean("" + i % max, 2));
      } else if (i == top + 1 || i == top + max + 1) {
        dataList.add(new ItemBean("" + i % max, 1));
      } else if (i == top + 3 || i == top + max + 3) {
        dataList.add(new ItemBean("" + i % max, 1));
      } else if (i == top || i == top + max) {
        dataList.add(new ItemBean("" + i % max, -1));
      } else if (i == top + 4 || i == top + max + 4) {
        dataList.add(new ItemBean("" + i % max, -10));
      } else {

        dataList.add(new ItemBean("" + i % max, 0));
      }
    }

    m1111 = new MyAdapter(this, dataList);
    listView.setAdapter(m1111);

    listView.setVerticalScrollBarEnabled(false);
    // listView.setSelection(32);

    listView.setOnScrollListener(this);
    listView.setOnTouchListener(this);
    listView.setOnItemClickListener(this);

    ObjectAnimator.ofFloat(m1, "Alpha", 1F, 0.0F).setDuration(10).start();

    new Thread(
            new Runnable() {

              public void run() {

                try {
                  Thread.sleep(1000);
                } catch (InterruptedException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
                listView.smoothScrollToPosition(35);
              }
            })
        .start();
  }
Ejemplo n.º 15
0
 private void vibrate() {
   Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
   // vibrator.vibrate(2000);   //震动2s
   vibrator.vibrate(new long[] {1000, 2000, 2000, 3000}, -1); // 第一个long数组先等待1s再震动2s,然后等待2s再震动3s
   // 第二个参数-1代表不循环,0表示从头儿开始循环
   // vibrator.cancel();   //取消震动
 }
Ejemplo n.º 16
0
  public void handleResult(
      final Result scanResult, final Bitmap thumbnailImage, final float thumbnailScaleFactor) {
    vibrator.vibrate(VIBRATE_DURATION);

    // superimpose dots to highlight the key features of the qr code
    final ResultPoint[] points = scanResult.getResultPoints();
    if (points != null && points.length > 0) {
      final Paint paint = new Paint();
      paint.setColor(getResources().getColor(R.color.scan_result_dots));
      paint.setStrokeWidth(10.0f);

      final Canvas canvas = new Canvas(thumbnailImage);
      canvas.scale(thumbnailScaleFactor, thumbnailScaleFactor);
      for (final ResultPoint point : points) canvas.drawPoint(point.getX(), point.getY(), paint);
    }

    scannerView.drawResultBitmap(thumbnailImage);

    final Intent result = new Intent();
    result.putExtra(INTENT_EXTRA_RESULT, scanResult.getText());
    setResult(RESULT_OK, result);

    // delayed finish
    new Handler()
        .post(
            new Runnable() {
              @Override
              public void run() {
                finish();
              }
            });
  }
Ejemplo n.º 17
0
 public void vibrate() {
   Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
   long[] pattern = {0, 500, 50, 300};
   // -1 to not repeat
   final int indexInPatternToRepeat = -1;
   vibrator.vibrate(pattern, indexInPatternToRepeat);
 }
Ejemplo n.º 18
0
 /** 用于播放提醒时的音乐和震动 */
 private void playMusic() {
   try {
     int position1 = MainActivity.music.musics;
     if (position1 == 0) mMediaPlayer = MediaPlayer.create(BusReminder.this, R.raw.big);
     if (position1 == 1) mMediaPlayer = MediaPlayer.create(BusReminder.this, R.raw.clubbin);
     if (position1 == 2) mMediaPlayer = MediaPlayer.create(BusReminder.this, R.raw.fallingstar);
     if (position1 == 3) mMediaPlayer = MediaPlayer.create(BusReminder.this, R.raw.onlyhuman);
     if (position1 == 4) mMediaPlayer = MediaPlayer.create(BusReminder.this, R.raw.whiteflag);
     if (mMediaPlayer != null) {
       mMediaPlayer.stop();
     }
     if (!playing) {
       playing = true;
       mMediaPlayer.prepare();
       int timeLength = MainActivity.music.times;
       if (MainActivity.music.ways != 2) {
         mMediaPlayer.start();
       }
       if (MainActivity.music.ways == 1) {
         mVibrator.vibrate(timeLength);
         Toast.makeText(BusReminder.this, "震动提醒", Toast.LENGTH_SHORT).show();
       }
       // thread=new Thread(new Player());
       // thread.start();
     }
   } catch (Exception e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     // System.out.println("error");
   }
 }
Ejemplo n.º 19
0
  /**
   * Do not call this directly. Use {@link #reboot(Context, String, boolean)} or {@link
   * #shutdown(Context, boolean)} instead.
   *
   * @param reboot true to reboot or false to shutdown
   * @param reason reason for reboot
   */
  public static void rebootOrShutdown(boolean reboot, String reason) {
    if (reboot) {
      Log.i(TAG, "Rebooting, reason: " + reason);
      try {
        PowerManagerService.lowLevelReboot(reason);
      } catch (Exception e) {
        Log.e(TAG, "Reboot failed, will attempt shutdown instead", e);
      }
    } else if (SHUTDOWN_VIBRATE_MS > 0) {
      // vibrate before shutting down
      Vibrator vibrator = new SystemVibrator();
      try {
        vibrator.vibrate(SHUTDOWN_VIBRATE_MS);
      } catch (Exception e) {
        // Failure to vibrate shouldn't interrupt shutdown.  Just log it.
        Log.w(TAG, "Failed to vibrate during shutdown.", e);
      }

      // vibrator is asynchronous so we need to wait to avoid shutting down too soon.
      try {
        Thread.sleep(SHUTDOWN_VIBRATE_MS);
      } catch (InterruptedException unused) {
      }
    }

    // Shutdown power
    Log.i(TAG, "Performing low-level shutdown...");
    PowerManagerService.lowLevelShutdown();
  }
Ejemplo n.º 20
0
  /** 设置闹铃 */
  private void setAlarm() {

    Iterator<Map.Entry<String, Integer>> iterator = map.entrySet().iterator();
    while (iterator.hasNext()) {
      Map.Entry<String, Integer> entry = iterator.next();
      String key = entry.getKey();
      try {
        if (ringStr.equals(key)) {
          alarmMusic = MediaPlayer.create(this, map.get(key));
          System.out.println("value" + map.get(key) + "//" + "key=" + key);
        }
      } catch (Exception e) {
        // TODO: handle exception
        alarmMusic = MediaPlayer.create(this, R.raw.a);
      }
    }
    // 设置为循环播放
    alarmMusic.setLooping(true);
    // 获取震动
    mVibrator = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
    // 震动时长与音乐播放时长一样,放在MediaPlayer.create()之后,不然报错null object reference
    // mVibrator.vibrate(alarmMusic.getDuration());
    mVibrator.vibrate(new long[] {1000, 2000, 1000, 2000, 1000}, 0);
    // 调节到最大音量
    // mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, max, AudioManager.FLAG_PLAY_SOUND);

    // 闹铃响
    alarmMusic.start();
  }
 private void notifyUser() {
   if (!sound) return;
   Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
   v.vibrate(500);
   if (player == null) player = MediaPlayer.create(this, R.raw.dice);
   player.start();
 }
Ejemplo n.º 22
0
  @Override
  public void onReceive(Context context, Intent intent) {
    System.out.println("**** Long Break ****");

    if (AsyncMovementTracker.isBreakCompleted()) {

      Notif notification = new Notif();
      notification.notifyUser(context);

      Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
      long[] vibratePattern = {100, 300, 100, 300, 100, 300};
      vibrator.vibrate(vibratePattern, -1);

      /* should not call new tva because it nulls all the intents for the alarms */
      musicIntent = new Intent(context, MusicService.class);
      context.startService(musicIntent);

      TimerViewActivity.setAccelerometer(new AsyncAccelerometer());
      TimerViewActivity.startAsyncAccelerometer();

      AsyncMovementTracker tracker = new AsyncMovementTracker(context);
      tracker.execute();
    } else {
      System.out.println("Break completed? " + AsyncMovementTracker.isBreakCompleted());
    }
  }
Ejemplo n.º 23
0
  /** 设置闹铃 */
  private void setAlarm() {

    alarmMusic = MediaPlayer.create(this, R.raw.a);
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    max = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_SYSTEM);
    current = mAudioManager.getStreamVolume(AudioManager.STREAM_SYSTEM);

    Iterator<Map.Entry<String, Integer>> iterator = map.entrySet().iterator();
    while (iterator.hasNext()) {
      Map.Entry<String, Integer> entry = iterator.next();
      String key = entry.getKey();
      try {
        if (clockModel.getRing().equals(key)) {
          alarmMusic = MediaPlayer.create(this, map.get(key));
        }
      } catch (Exception e) {
        alarmMusic = MediaPlayer.create(this, R.raw.a);
      }
    }
    // 设置为循环播放
    alarmMusic.setLooping(true);
    // 获取震动
    mVibrator = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
    // 震动时长与音乐播放时长一样,放在MediaPlayer.create()之后,不然报错null object reference
    // mVibrator.vibrate(alarmMusic.getDuration());
    mVibrator.vibrate(new long[] {1000, 2000, 1000, 2000, 1000}, 0);
    // 调节到最大音量
    mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, max, AudioManager.FLAG_PLAY_SOUND);

    // 闹铃响
    alarmMusic.start();
  }
Ejemplo n.º 24
0
 @Override
 public void onSelectionModeChange(int mode) {
   switch (mode) {
     case SelectionManager.ENTER_SELECTION_MODE:
       {
         mActionBar.disableClusterMenu(true);
         mActionModeHandler.startActionMode();
         if (mHapticsEnabled) mVibrator.vibrate(100);
         break;
       }
     case SelectionManager.LEAVE_SELECTION_MODE:
       {
         mActionModeHandler.finishActionMode();
         if (mShowClusterMenu) {
           mActionBar.enableClusterMenu(mSelectedAction, this);
         }
         mRootPane.invalidate();
         break;
       }
     case SelectionManager.SELECT_ALL_MODE:
       {
         mActionModeHandler.updateSupportedOperation();
         mRootPane.invalidate();
         break;
       }
   }
 }
Ejemplo n.º 25
0
 public void vibrateQuick() {
   // Start without a delay
   // Vibrate for 100 milliseconds
   // Sleep for 1000 milliseconds
   long[] pattern = {0, 100, 100, 100, 100};
   mVibrator.vibrate(pattern, -1);
 }
Ejemplo n.º 26
0
 public void vibrate(long[] pattern, int repeat) {
   try {
     mVibrator.vibrate(pattern, repeat);
   } catch (Exception e) {
     // Do nothing
   }
 }
 private void keyboardVibrate() {
   int vibTime = KeypadMapperApplication.getInstance().getSettings().getKeyboardVibrationTime();
   if (vibTime != 0) {
     Vibrator vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
     vibrator.vibrate(vibTime);
   }
 }
Ejemplo n.º 28
0
  private void vibrate() {
    Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

    long[] pattern = {0, 500, 200};

    v.vibrate(pattern, 0);
  }
 /**
  * Generate the haptic feedback vibration. Only one thread can request it. If the phone is already
  * in a middle of an haptic feedback sequence, the request is ignored.
  */
 public void vibrateFromDialpad(int mode) {
   if (mode == 0) {
     return;
   } else if (mode == 1) {
     mVibrator.vibrate(mHapticPattern, NO_REPEAT);
   }
 }
 private void select(int x, int y) {
   Vibrator vb = (Vibrator) persistentBoggleGame.getSystemService(Context.VIBRATOR_SERVICE);
   int event = this.persistentBoggleGame.selectTile(x + (y * rows));
   if (event == 1) {
     // invalidate(selRect.get(selRect.size()-1));
     int newSelX = Math.min(Math.max(x, 0), 8);
     int newSelY = Math.min(Math.max(y, 0), 8);
     // Add selected indices to x and y lists
     selX.add(newSelX);
     selY.add(newSelY);
     // Get newly selected rectangle
     Rect rect = getRect(newSelX, newSelY, new Rect());
     // Add rectangle to selected list
     selRect.add(rect);
     invalidate(selRect.get(selRect.size() - 1));
     vb.vibrate(10);
   } else if (event == 2) {
     selX.clear();
     selY.clear();
     for (Rect r : selRect) invalidate(r);
     selRect.clear();
   } else if (event == 3) {
     // Remove last selected
     selX.remove(selX.size() - 1);
     selY.remove(selY.size() - 1);
     invalidate(selRect.get(selRect.size() - 1));
     selRect.remove(selRect.size() - 1);
   }
 }