當前位置: 首頁>>代碼示例>>Java>>正文


Java Vibrator類代碼示例

本文整理匯總了Java中android.os.Vibrator的典型用法代碼示例。如果您正苦於以下問題:Java Vibrator類的具體用法?Java Vibrator怎麽用?Java Vibrator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Vibrator類屬於android.os包,在下文中一共展示了Vibrator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initParams

import android.os.Vibrator; //導入依賴的package包/類
private void initParams() {
    mStartX = 0;
    mStartY = 0;
    mKeyWidth = LayoutParams.MATCH_PARENT;
    mKeyHeight = getSaftyKeyHeight() / 15;
    mTitleHeight = getSaftyKeyHeight() / 16;
    mMarginCol = 10;
    mMarginRow = 10;
    mPaddingLeft = 0;
    mPaddingTop = 0;
    mPaddingRight = 0;
    mPaddingBottom = 0;
    mWidth = LayoutParams.MATCH_PARENT;
    mHeight = getSaftyKeyboardHeight();
    try {
        mVibrator = (Vibrator) mContext
                .getSystemService(Context.VIBRATOR_SERVICE);
    } catch (Exception e) {
        e.getStackTrace();
    }
    mAudioManger = (AudioManager) mContext
            .getSystemService(Context.AUDIO_SERVICE);
    mSoundEffect = Settings.System.SOUND_EFFECTS_ENABLED
            .equals("sound_effects_enabled");
    mAdapter = new KeyBoardDataAdapter();
}
 
開發者ID:VigorousLiang,項目名稱:PWEditText-SafeKeyboard,代碼行數:27,代碼來源:SafetyKeyboard.java

示例2: getNonIndexableKeys

import android.os.Vibrator; //導入依賴的package包/類
public List<String> getNonIndexableKeys(Context context) {
    final ArrayList<String> rt = new ArrayList<String>();
    if (Utils.isVoiceCapable(context)) {
        rt.add(KEY_NOTIFICATION_VOLUME);
    } else {
        rt.add(KEY_RING_VOLUME);
        rt.add(KEY_PHONE_RINGTONE);
        rt.add(KEY_WIFI_DISPLAY);
        rt.add(KEY_VIBRATE_WHEN_RINGING);
    }
    Vibrator vib = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
    if (vib == null || !vib.hasVibrator()) {
        rt.add(KEY_VIBRATE);
    }
    CMHardwareManager hardware = CMHardwareManager.getInstance(context);
    if (!hardware.isSupported(CMHardwareManager.FEATURE_VIBRATOR)) {
        rt.add(KEY_VIBRATION_INTENSITY);
    }

    return rt;
}
 
開發者ID:ric96,項目名稱:lineagex86,代碼行數:22,代碼來源:SoundSettings.java

示例3: onCreate

import android.os.Vibrator; //導入依賴的package包/類
@SuppressWarnings("WrongConstant")
@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    Activity activity = getActivity();
    activity.getWindow().setSoftInputMode(
            WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    mVibrator = ((Vibrator) activity.getSystemService("vibrator"));
    if (bundle != null) {
        mCalendar.set(Calendar.YEAR, bundle.getInt(KEY_SELECTED_YEAR));
        mCalendar.set(Calendar.MONTH, bundle.getInt(KEY_SELECTED_MONTH));
        mCalendar.set(Calendar.DAY_OF_MONTH,
                bundle.getInt(KEY_SELECTED_DAY));
        mVibrate = bundle.getBoolean(KEY_VIBRATE);
    }
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:17,代碼來源:DatePickerDialog.java

示例4: onCreate

import android.os.Vibrator; //導入依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();
    mInstance = this;
    // 通過代碼注冊你的AppKey和AppSecret
    MobSDK.init(this, "201f8a7a91c30", "c63ec5c1eeac1f873ec78c1365120431");

    sContext = getApplicationContext();
    initUser();
    Utils.init(this);

    locationService = new LocationService(getApplicationContext());
    mVibrator =(Vibrator)getApplicationContext().getSystemService(Service.VIBRATOR_SERVICE);

    //配置數據庫
    setupDatabase();

}
 
開發者ID:gaolhjy,項目名稱:cniao5,代碼行數:19,代碼來源:CNiaoApplication.java

示例5: showNotification

import android.os.Vibrator; //導入依賴的package包/類
protected void showNotification(String notificationText) {
    // TODO Auto-generated method stub
    NotificationCompat.Builder build = new NotificationCompat.Builder(
            activity);
    build.setSmallIcon(OneSheeldApplication.getNotificationIcon());
    build.setContentTitle(notificationText);
    build.setContentText(activity.getString(R.string.notifications_notification_received_from_1sheeld));
    build.setTicker(notificationText);
    build.setWhen(System.currentTimeMillis());
    Toast.makeText(activity, notificationText, Toast.LENGTH_SHORT).show();
    Vibrator v = (Vibrator) activity
            .getSystemService(Context.VIBRATOR_SERVICE);
    v.vibrate(1000);
    Intent notificationIntent = new Intent(activity, MainActivity.class);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
            | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent intent = PendingIntent.getActivity(activity, 0,
            notificationIntent, 0);
    build.setContentIntent(intent);
    Notification notification = build.build();
    NotificationManager notificationManager = (NotificationManager) activity
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(2, notification);
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:25,代碼來源:NotificationShield.java

示例6: shouldVibrateNew

import android.os.Vibrator; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private boolean shouldVibrateNew(Context context, int ringerMode) {
    Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);

    if (vibrator == null || !vibrator.hasVibrator()) {
        return false;
    }

    boolean vibrateWhenRinging = Settings.System.getInt(context.getContentResolver(), "vibrate_when_ringing", 0) != 0;

    if (vibrateWhenRinging) {
        return ringerMode != AudioManager.RINGER_MODE_SILENT;
    } else {
        return ringerMode == AudioManager.RINGER_MODE_VIBRATE;
    }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:17,代碼來源:IncomingRinger.java

示例7: onReceive

import android.os.Vibrator; //導入依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    int alertValue = PreferenceManager.getDefaultSharedPreferences(context).getInt(MainActivity.KEY_BATTERY_PERCENT, 20);

    int status = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
    int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
    float level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
    float scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);

    boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || plugged == BatteryManager.BATTERY_PLUGGED_USB || plugged == BatteryManager.BATTERY_PLUGGED_AC;
    float value = (level * 100f) / scale;

    if (!isCharging && (int) value == alertValue) {
        ((Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE)).vibrate(3000);
        Toast.makeText(context, String.format(context.getString(R.string.msg_low_battery), (int) value), Toast.LENGTH_LONG).show();
    }
}
 
開發者ID:TheAndroidMaster,項目名稱:BatteryAlert,代碼行數:18,代碼來源:BatteryReceiver.java

示例8: showNotification

import android.os.Vibrator; //導入依賴的package包/類
protected void showNotification(String notificationText) {
    // TODO Auto-generated method stub
    NotificationCompat.Builder build = new NotificationCompat.Builder(
            activity);
    build.setSmallIcon(OneSheeldApplication.getNotificationIcon());
    build.setContentTitle(activity.getString(R.string.data_logger_shield_name));
    build.setContentText(notificationText);
    build.setTicker(notificationText);
    build.setWhen(System.currentTimeMillis());
    build.setAutoCancel(true);
    Toast.makeText(activity, notificationText, Toast.LENGTH_SHORT).show();
    Vibrator v = (Vibrator) activity
            .getSystemService(Context.VIBRATOR_SERVICE);
    v.vibrate(1000);
    Intent notificationIntent = new Intent(Intent.ACTION_VIEW);
    MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
    String mimeFileType = mimeTypeMap.getMimeTypeFromExtension("csv");
    if(Build.VERSION.SDK_INT>=24) {
        Uri fileURI = FileProvider.getUriForFile(activity,
                BuildConfig.APPLICATION_ID + ".provider",
                new File(filePath == null || filePath.length() == 0 ? "" : filePath));
        notificationIntent.setDataAndType(fileURI, mimeFileType);
    }
    else{
        notificationIntent.setDataAndType(Uri.fromFile(new File(filePath == null
                || filePath.length() == 0 ? "" : filePath)), mimeFileType);
    }
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    notificationIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    PendingIntent intent = PendingIntent.getActivity(activity, 0,
            notificationIntent, 0);
    build.setContentIntent(intent);
    Notification notification = build.build();
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    NotificationManager notificationManager = (NotificationManager) activity
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify((int) new Date().getTime(), notification);
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:39,代碼來源:DataLoggerShield.java

示例9: init

import android.os.Vibrator; //導入依賴的package包/類
/**
 * this function can be override
 * @param context
 * @return
 */
public EaseNotifier init(Context context){
    appContext = context;
    notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    packageName = appContext.getApplicationInfo().packageName;
    if (Locale.getDefault().getLanguage().equals("zh")) {
        msgs = msg_ch;
    } else {
        msgs = msg_eng;
    }

    audioManager = (AudioManager) appContext.getSystemService(Context.AUDIO_SERVICE);
    vibrator = (Vibrator) appContext.getSystemService(Context.VIBRATOR_SERVICE);

    return this;
}
 
開發者ID:funnyzhaov,項目名稱:Tribe,代碼行數:22,代碼來源:EaseNotifier.java

示例10: init

import android.os.Vibrator; //導入依賴的package包/類
/**
 * this function can be override
 * @param context
 * @return
 */
public EaseNotifier init(Context context){
    appContext = context;
    notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    packageName = appContext.getApplicationInfo().packageName;
    if (Locale.getDefault().getLanguage().equals("zh")) {
        msgs = msg_ch;
    } else {
        msgs = msg_eng;
    }

    audioManager = (AudioManager) appContext.getSystemService(Context.AUDIO_SERVICE);
    vibrator = (Vibrator) appContext.getSystemService(Context.VIBRATOR_SERVICE);
    
    return this;
}
 
開發者ID:funnyzhaov,項目名稱:Tribe,代碼行數:22,代碼來源:EaseNotifier.java

示例11: run

import android.os.Vibrator; //導入依賴的package包/類
@Override
public void run() {
    Vibrator vibrator= (Vibrator)mContext.getSystemService(Context.VIBRATOR_SERVICE);
    vibrator.vibrate(10);
    if (currentKeyCode == KeyEvent.KEYCODE_BACK){
        isLongPressedCancel = true;
    }else {
        isLongPressedCancel = false;
    }
    if (currentKeyCode==KeyEvent.KEYCODE_HOME){
        isLongPressedHome = true;
    }
    if (currentKeyCode==KeyEvent.KEYCODE_APP_SWITCH){
        isLongPressedRecent = true;
    }
    KeyPressedTipViewController.getInstance().show(null);
}
 
開發者ID:l465659833,項目名稱:Bigbang,代碼行數:18,代碼來源:KeyPressedTipViewController.java

示例12: initPreferences

import android.os.Vibrator; //導入依賴的package包/類
@Override
public void initPreferences() {
    if (Utils.hasVibrator(mContext)) {
        mHasVibrator = true;
        mVibrator = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
    }

    Set<String> smodes = mPrefs.getStringSet(
            GravityBoxSettings.PREF_KEY_RINGER_MODE_TILE_MODE,
            new HashSet<String>(Arrays.asList(new String[] { "1", "2", "3" })));
    List<String> lmodes = new ArrayList<String>(smodes);
    Collections.sort(lmodes);
    int modes[] = new int[lmodes.size()];
    for (int i=0; i<lmodes.size(); i++) {
        modes[i] = Integer.valueOf(lmodes.get(i));
    }
    if (DEBUG) log(getKey() + ": onPreferenceInitialize: modes=" + Arrays.toString(modes));
    updateSettings(modes);

    mQuickMode = Utils.isOxygenOs35Rom() ? true :
            mPrefs.getBoolean(GravityBoxSettings.PREF_KEY_RINGER_MODE_TILE_QUICK_MODE, false);

    super.initPreferences();
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:25,代碼來源:RingerModeTile.java

示例13: onHandleIntent

import android.os.Vibrator; //導入依賴的package包/類
@Override
protected void onHandleIntent(Intent intent) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    // Play a click sound and vibrate quickly
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    AudioManager audioManager = (AudioManager)getSystemService(AUDIO_SERVICE);
    audioManager.playSoundEffect(SoundEffectConstants.CLICK, 1.0f);
    Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
    vibrator.vibrate(VIBRATOR_PULSE);

    try {
        Bundle data = new Bundle();
        data.putString("user",
                sharedPreferences.getString(GarageDoorWidgetProvider.PREF_USERNAME, ""));
        data.putString("password",
                sharedPreferences.getString(GarageDoorWidgetProvider.PREF_PASSWORD, ""));
        data.putString("timestamp", String.valueOf(System.currentTimeMillis() / 1000));

        String id = Integer.toString(getNextMsgId());
        gcm.send(GarageDoorWidgetProvider.GCM_SENDER_ID + "@gcm.googleapis.com",
                id, TIME_TO_LIVE, data);
    } catch (IOException e) {
        Log.e(TAG, "Error sending message", e);
    }
}
 
開發者ID:jpuderer,項目名稱:GarageDoor,代碼行數:27,代碼來源:GarageDoorIntentService.java

示例14: Player

import android.os.Vibrator; //導入依賴的package包/類
/**
 * Creates a new Player component.
 *
 * @param container
 */
public Player(ComponentContainer container) {
  super(container.$form());
  activity = container.$context();
  sourcePath = "";
  vibe = (Vibrator) form.getSystemService(Context.VIBRATOR_SERVICE);
  form.registerForOnDestroy(this);
  form.registerForOnResume(this);
  form.registerForOnPause(this);
  form.registerForOnStop(this);
  // Make volume buttons control media, not ringer.
  form.setVolumeControlStream(AudioManager.STREAM_MUSIC);
  loop = false;
  playOnlyInForeground = false;
  focusOn = false;
  am = (audioFocusSupported) ? FroyoUtil.setAudioManager(activity) : null;
  afChangeListener = (audioFocusSupported) ? FroyoUtil.setAudioFocusChangeListener(this) : null;
}
 
開發者ID:mit-cml,項目名稱:appinventor-extensions,代碼行數:23,代碼來源:Player.java

示例15: onClick

import android.os.Vibrator; //導入依賴的package包/類
@Override
public void onClick(View view) {
    Vibrator vibrator = (Vibrator) view.getContext().getSystemService(Context.VIBRATOR_SERVICE);
    long[] pattern = {0,15,10,15,10,15};
    vibrator.vibrate(pattern,-1);
    int pos = getLayoutPosition();  // getAdapterPosition() may return -1 and produce an error
    int max_dice = Integer.parseInt(mFaces.get(pos));
    int new_num = random.nextInt(max_dice) + 1;
    mData.set(pos, String.valueOf(new_num));
    notifyDataSetChanged();
    RollingRunnable rollingRunnable = new RollingRunnable(pos, max_dice);
    handler.postDelayed(rollingRunnable, 50);
    handler.postDelayed(rollingRunnable, 110);
    handler.postDelayed(rollingRunnable, 190);
    handler.postDelayed(rollingRunnable, 280);
    if (random.nextBoolean()){
        handler.postDelayed(rollingRunnable, 500);
    }
}
 
開發者ID:ndleyton,項目名稱:OneTwo,代碼行數:20,代碼來源:DiceListAdapter.java


注:本文中的android.os.Vibrator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。