当前位置: 首页>>代码示例>>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;未经允许,请勿转载。