*

【android】バイブレーションを使う

公開日: : android

必要なファイル

  • MyApp.manifest
  • MyApp.java

MyApp.manifest

パーミッションを追加

<uses-permission android:name="android.permission.VIBRATE"/>

MyApp.java

実行

//インスタンスを取得
Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);

//振動パターンをlongの配列で作成
long[] pattern = new long[]{0,150,150,150,150};

//繰り返し回数。-1でループ
int repeat = -1;

//振動開始
vibrator.vibrate(pattern, repeat);
vibrator.vibrate(100);//ミリ秒で振動

//振動をキャンセル
vibrator.cancel();

関連記事

no image

【android】設定画面の作成

res/xml/preferences.xml <?xml version=&quo

記事を読む

no image

【android】アプリ内課金を実装する

アプリ内課金のサンプルコードを解析します。 参考URL 公式API Android

記事を読む

no image

【android】言語・地域設定の取得

androidでは利用する言語と国名がjava.util.Localeのオブジェクトとして設定されて

記事を読む

no image

【android】 setOnClickListener(false)が効かない

間違いその1 OnClickListenerが登録されているViewにsetClickable

記事を読む

no image

インテント

基本 //任意のアクティビティの起動 Intent intent = new

記事を読む

no image

【android】Activityとプロセスのライフサイクル

またもやライフサイクル周りでハマったのですが、Androidのライフサイクルは複雑で困ります。 G

記事を読む

no image

【android】標準の設定画面を作る

設定画面のテンプレートです。 検索一発クンのコードから抜粋しました。 チェックボックス、リス

記事を読む

no image

【android】 Android4.1のserviceでdefaultPreferenceがおかしい

【現象】 ActivityでdefaultPreferencesで保存したデータがservice内

記事を読む

no image

【android】アプリのバージョン情報を取得する

int versionCode = -1; String versionName = &quo

記事を読む

no image

【android】ホーム画面や他のアプリの前面にViewを表示する。

WindowManagerのTYPE_SYSTEM_ALERTのレイヤーにViewを表示することで、

記事を読む

Message

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

次のHTML タグと属性が使えます: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

no image
知らないと損をする6つのライセンスまとめ

オープンソースやフリーウェア、フリー素材などが巷に溢れ、それらを利用す

no image
ガリレオ:ニュースブラウザをリリースしました。

概要 ガリレオはニュースを読んだり、検索する機能に特化したブラウザア

no image
【android】Activityとプロセスのライフサイクル

またもやライフサイクル周りでハマったのですが、Androidのライフサ

→もっと見る

PAGE TOP ↑