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);
   }
 }
 @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);
 }
  public void newMessage(IrcMessage msg) {
    if ((!preferences.isSpamFilterEnabled()
        || new Date().getTime()
            > IrcNotificationManager.getInstance().getLastSoundDate() + 60000L)) {
      Uri sound = preferences.getNotificationSound();
      if (sound != null) {
        MediaPlayer mp = MediaPlayer.create(this, sound);
        if (mp != null) {
          mp.start();
        }
      }

      if (preferences.isVibrationEnabled()) {
        Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
        if (v != null) {
          v.vibrate(500);
        }
      }

      IrcNotificationManager.getInstance().setLastSoundDate(new Date().getTime());
    }

    if (preferences.isFeedViewDefault()) {
      channelToView = FEED;
    } else {
      channelToView = msg.getLogicalChannel();
    }
    startMainApp(false);
  }
Ejemplo n.º 4
0
  private void vibrate() {
    Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

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

    v.vibrate(pattern, 0);
  }
Ejemplo n.º 5
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.º 6
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.º 7
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.º 8
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.º 9
0
    @Override
    public void handleMessage(Message msg) {

      if (D) Log.d(TAG, "In the Handler");
      switch (msg.what) {
        case NetworkService.MSG_RECIEVED:
          // New message coming
          String incomingPeerAddr = msg.getData().getString("peerAddress");
          String incomingMessage = msg.getData().getString("content");

          // Shake
          Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
          v.vibrate(300);

          // Notify by Toast
          if (!friendsOnShow.contains(incomingPeerAddr)) {
            friendItems.add(new UserPreference(incomingPeerAddr));
            friendsOnShow.add(incomingPeerAddr);
          }

          String toastToMake = incomingPeerAddr + " send you an message";
          Toast.makeText(getApplicationContext(), toastToMake, Toast.LENGTH_SHORT).show();

          Utils.chatHistory.addSnts(incomingPeerAddr, "You", incomingMessage);
          Utils.chatHistory.setUnRead(incomingPeerAddr);

          friendItems.notifyDataSetChanged();

          // add unread marks, waiting to be read.
          Log.i("IncomingMessage", incomingMessage);
          break;
        default:
          super.handleMessage(msg);
      }
    }
Ejemplo n.º 10
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();
  }
 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.º 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
  public void payan() {
    if (MainActivity.sound) {
      if (mp_motevaset.isPlaying()) {
        mp_motevaset.stop();
        mp_motevaset.reset();
        mp_motevaset.release();
        mp_motevaset = null;
      }
    }
    // namayesh emtiaz va az sar giri
    int bestresult = pref.getInt("best_result_motevaset", 0);
    String bestresult_string = String.valueOf(bestresult);

    String emtiaz = String.valueOf(count);
    Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(500);
    // mire b activitie result va natijeha ra ha mibarad

    Intent result_intent = new Intent(getApplicationContext(), Result.class);
    Bundle extras = new Bundle();
    extras.putString("emtiaz", emtiaz);
    extras.putString("best_emtiaz", bestresult_string);
    extras.putString("level", "motevaset");
    result_intent.putExtras(extras);
    startActivity(result_intent);
    overridePendingTransition(R.anim.left, R.anim.abc_fade_out);
    onDestroy();
  }
Ejemplo n.º 14
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);
  }
  protected void setVibrateTo(boolean on) {

    if (Log.DEBUG) Log.d("on = " + on);

    if (on && _vibrateIsMuted) {

      _vibrateIsMuted = false;

      if (_defaultVibrateSettings == AudioManager.VIBRATE_SETTING_OFF) {
        return;
      }

      _audioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, _defaultVibrateSettings);
      _audioManager.setVibrateSetting(
          AudioManager.VIBRATE_TYPE_NOTIFICATION, _defaultVibrateSettings);
    }

    if (!on && !_vibrateIsMuted) {

      _vibrateIsMuted = true;

      _defaultVibrateSettings = _audioManager.getVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER);
      if (_defaultVibrateSettings == AudioManager.VIBRATE_SETTING_OFF) {
        return;
      }

      _vibrator.cancel();
      _audioManager.setVibrateSetting(
          AudioManager.VIBRATE_TYPE_RINGER, AudioManager.VIBRATE_SETTING_OFF);
      _audioManager.setVibrateSetting(
          AudioManager.VIBRATE_TYPE_NOTIFICATION, AudioManager.VIBRATE_SETTING_OFF);
      _vibrator.cancel();
    }
  }
 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.º 17
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.º 18
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.º 19
0
 /** 播放声音和震动 */
 private void playBeepSoundAndVibrate() {
   if (playBeep && mediaPlayer != null) {
     mediaPlayer.start();
   }
   // 打开震动
   Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
   vibrator.vibrate(VIBRATE_DURATION);
 }
Ejemplo n.º 20
0
        public boolean onLongClick(View v) {
          eraserButton.setChecked(true);
          Vibrator vibrator = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
          vibrator.vibrate(40);
          mEraseMenuWindow.show();

          return true;
        }
Ejemplo n.º 21
0
 public void resetLayout(View v) {
   Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
   vibrator.vibrate(vibr);
   matrix = new Matrix();
   captImg[0].setScaleType(ImageView.ScaleType.MATRIX);
   captImg[0].setImageMatrix(matrix);
   captImg[1].setScaleType(ImageView.ScaleType.MATRIX);
   captImg[1].setImageMatrix(matrix);
 }
Ejemplo n.º 22
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
   v.cancel();
   if (this.wakeLock.isHeld()) {
     this.wakeLock.release();
   }
 }
 /**
  * The user can touch the icon and a little vibration occurs along with a small message
  *
  * @param v the default param for onClick methods
  */
 public void onClickIcon(View v) {
   if (easterEgg == null) {
     easterEgg =
         Toast.makeText(getApplicationContext(), "You found the easter egg!", Toast.LENGTH_SHORT);
   }
   easterEgg.show();
   Vibrator a = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
   a.vibrate(50);
 }
Ejemplo n.º 24
0
 public synchronized void playBeepSoundAndVibrate() {
   if (playBeep && mediaPlayer != null) {
     mediaPlayer.start();
   }
   if (vibrate) {
     Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
     vibrator.vibrate(VIBRATE_DURATION);
   }
 }
Ejemplo n.º 25
0
  @Override
  public void onReceive(Context arg0, Intent arg1) {
    // TODO Auto-generated method stub

    cal = Calendar.getInstance();
    alarm_cal = Calendar.getInstance();
    cal.setTimeInMillis(System.currentTimeMillis());
    int minutes = cal.get(Calendar.MINUTE);
    int hour = cal.get(Calendar.HOUR_OF_DAY);
    whichWeek = cal.get(Calendar.DAY_OF_WEEK);
    String currentTime = "";
    if (minutes <= 9 && minutes >= 0) {
      currentTime = hour + ":0" + minutes;
    } else {
      currentTime = hour + ":" + minutes;
    }
    if ("android.closeservice".equals(arg1.getAction())) {
      Intent closeService = new Intent("android.closeservice");
      arg0.stopService(closeService);
      Toast.makeText(arg0, "关闭service", Toast.LENGTH_LONG).show();
    }

    if ("android.alarm.demo.action".equals(arg1.getAction())) {
      alarm_cal.set(Calendar.HOUR_OF_DAY, arg1.getIntExtra("hour", 0));
      alarm_cal.set(Calendar.MINUTE, arg1.getIntExtra("minute", 0));
      alarm_cal.set(Calendar.SECOND, 0);
      week = arg1.getStringExtra("week");
      message = arg1.getStringExtra("message");

      System.out.println("time" + arg1.getStringExtra("time"));
      System.out.println("alarmreceiver" + week);
      //			System.out.println("aaaaaa");
      Intent serviceIntent = new Intent("android.start.service");
      serviceIntent.putExtra("address", arg1.getStringExtra("address"));
      if (arg1.getIntExtra("isAbled", 0) == 1) {
        if (alarm_cal.getTimeInMillis() == cal.getTimeInMillis()) {
          if (isToday(arg0, week) || (week.equals(""))) {
            Intent it = new Intent();
            it.setClass(arg0, NotiActivity.class);
            it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            arg0.startActivity(it);
            arg0.startService(serviceIntent);

            if (arg1.getIntExtra("isVirbate", 0) == 1) {
              Vibrator virbator = (Vibrator) arg0.getSystemService(Service.VIBRATOR_SERVICE);
              virbator.vibrate(60 * 10000);
              Toast.makeText(arg0, "virbate", Toast.LENGTH_LONG).show();
              System.out.println("virbate");
            }
            Toast.makeText(arg0, "闹钟来了", Toast.LENGTH_SHORT).show();
            showNotification(arg0);
          }
        }
      }
    }
  }
Ejemplo n.º 26
0
 public void vibrate(long[] pattern) {
   if (pattern == null) {
     pattern = DEFAULT_VIBRATE_PATTERN;
   }
   Vibrator vibrator =
       (Vibrator) getWebView().getContext().getSystemService(Context.VIBRATOR_SERVICE);
   if (vibrator != null) {
     vibrator.vibrate(pattern, -1);
   }
 }
Ejemplo n.º 27
0
 /**
  * @brief share method
  * @param v
  * @detail This method is called when the share button on the capture screen is clicked and will
  *     launch a list of applications which can do this operation
  */
 public void share(View v) {
   final Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
   vibrator.vibrate(vibr);
   int id = Integer.parseInt(v.getTag().toString());
   String path = savedPaths[id];
   final Intent shareIntent = new Intent(Intent.ACTION_SEND);
   shareIntent.setType("image/*");
   shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + path));
   startActivity(Intent.createChooser(shareIntent, "Share image using"));
 }
Ejemplo n.º 28
0
  @Override
  public void onReceive(Context context, Intent intent) {

    Log.i(TAG, "INTENT RECEIVED");

    Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    v.vibrate(500);

    Toast.makeText(context, "INTENT RECEIVED by Receiver", Toast.LENGTH_LONG).show();
  }
 private void vibrate() {
   Context context = getContext();
   if (Settings.System.getInt(
           context.getContentResolver(), Settings.System.HAPTIC_FEEDBACK_ENABLED, 1)
       != 0) {
     Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
     vibrator.vibrate(
         mResources.getInteger(R.integer.config_search_panel_view_vibration_duration));
   }
 }
Ejemplo n.º 30
0
 public void isVibrate(Context context, int type) {
   SPhelper sPhelper = new SPhelper(context);
   //		if(sPhelper.getToggleState().equals("true")||type==Constant.VIBRATOR_FROM_BACK)
   if (sPhelper.getToggleState().equals("true")) {
     // Vibrator实现手机震动效果
     Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
     vibrator.vibrate(200);
     System.out.println(sPhelper.getToggleState() + "============>>>>>>>>zhendong");
   }
 }