Merhabalar bu makalemi, özellikle farklı türde titreşimlerin nasıl yapıldığını öğrenmek isteyen geliştiriciler için hazırladım. Yararlı olması dileğiyle...

Öncelikle yeni bir örnek proje açıp, MainActivity içerisindeki onCreate methodu içerisinde iken,

  • Vibrator vib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
  • import olarak ise,
    import android.os.Vibrator;

Vibratör nesnemizi oluşturduk, sıra geldi pattern olarak tanımladığımız titreşim örneğine;

  • long[] pattern = { 0,150,50,75,50,75,50,150,50,75,50,75,50,300 }; //bu şekilde tanımlama yapmanız gerekmektedir.

Vibratör nesnemizi titretmek için ise, son olarak;

  • vib.vibrate(pattern , -1);

AndroidManifest.xml den izin almanız gerektiğini unutmayın;

  • uses-permission android:name="android.permission.VIBRATE"

Aşağıda denenmiş örnekler bulunmaktadır, yukarıdaki değişken içerisindeki değerleri değiştirerek sonuçları görebilirsiniz.

  • // other - 0,150,50,75,50,75,50,150,50,75,50,75,50,300
  • // Battlefield 4 Drum Rhythm - 175, 25, 100, 300, 100, 300, 100, 100, 100, 300, 200, 600
  • // Boney M - Rasputin - 200, 200, 200, 200, 100, 100, 100, 100, 100, 300, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 500, 100, 100, 100, 100, 100, 100, 100, 300, 200, 200, 100, 100, 100, 100, 100, 100, 100, 900
  • // Nocturne - 660, 60, 180, 60, 60, 180, 60, 180, 60, 180, 420, 60, 180, 60, 60, 180, 60, 180, 60, 180, 420, 60, 180, 60, 60, 180, 60, 180, 60, 180, 420, 60, 180, 60, 60, 180, 60, 180, 420, 60, 420, 60
  • //Düz - 1000, 500, 1000
  • //TesseracT - Perfection - 75,225,75,75,75,75,75,225,75,225,75,225,75,75,75,225,75,225,75,75,75,75,75,225,75,225,75,225,75,75,75,225,75,225,75,75,75,75,75,225,75,225,150,150,75,75,75,225,75,375,75,75,75,75,75,225,75,225,75,225,75,75,75,225,75,225,75,75,75,75,75,225,75,225,75,225,75,75,75,225,75,225,75,75,75,75,150,150
  • //TesseracT - Nocturne - 660,60,180,60,60,180,60,180,60,180,420,60,180,60,60,180,60,180,60,180,420,60,180,60,60,180,60,180,60,180,420,60,180,60,60,180,60,180,420,60,420,60
  • //Karnivool - Cote - 75,75,75,75,75,225,75,75,75,75,75,75,75,225,75,75,75,75,75,75,75,225,75,75,75,75,75,75,75,225,75,75,75,75,75,75,75,225,75,75,75,75,75,225,75,75,75,225,75,75,75,225,75,75,75,225,75,75,75,75,75,225,75,75,75,75,75,75,75,225,75,75,75,75,75,75,75,225,75,75,75,75,75,75,75,225,75,75,75,75,75,75,75,225,75,75,75,75,75,75
  • //Pain of Salvation - Nihil Morari - 50,50,50,50,50,50,50,550,300,300,100,200,50,50,50,50,50,50,50,250
  • //Muse - Madnes - 80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,80,320,160,320,160,320
  • //Dream Theater - Strange Déjà Vu Intro - 100,50,100,50,100,50,100,350,100,50,100,50,100,50,100,350,100,50,100,50,100,500,100,50,100,50,100,50,100,1400
  • //Dream Theater - Overture 1928 Intro - 75,25,75,25,75,25,75,525,75,25,75,25,75,25,75,25,75,25,75,25,75,225,75,25,75,25,75,25,75,225,75,25,75,25,75,25,75,525,75,25,75,25,75,25,75,25,75,25,75,25,75,225,75,25,75,25,75,25,75,225
  • //Dream Theater - Fatal Tragedy "What a phenomenon" - 75,38,75,488,75,38,75,200,75,38,75,400
  • //Michael Jackson - Smooth Criminal - 0,300,100,50,100,50,100,50,100,50,100,50,100,50,150,150,150,450,100,50,100,50,150,150,150,450,100,50,100,50,150,150,150,450,150,150
  • //Mortal Kombat Theme - 100,200,100,200,100,200,100,200,100,100,100,100,100,200,100,200,100,200,100,200,100,100,100,100,100,200,100,200,100,200,100,200,100,100,100,100,100,100,100,100,100,100,50,50,100,800
  • //James Bond 007 - 200,100,200,275,425,100,200,100,200,275,425,100,75,25,75,125,75,25,75,125,100,100
  • //Morse Code SOS - 100,30,100,30,100,200,200,30,200,30,200,200,100,30,100,30,100
  • //Shave and a Haircut - 100,200,100,100,75,25,100,200,100,500,100,200,100,500
  • //Go Go Power Rangers - 150,150,150,150,75,75,150,150,150,150,450
  • //Final Fantasy Victory Fanfare - 50,100,50,100,50,100,400,100,300,100,350,50,200,100,100,50,600
  • //Voltron Theme - 250,200,150,150,100,50,450,450,150,150,100,50,900,2250
  • //Teenage Mutant Ninja Turtles - 75,75,75,75,75,75,75,75,150,150,150,450,75,75,75,75,75,525
  • //Super Mario Theme Intro - 125,75,125,275,200,275,125,75,125,275,200,600,200,600
  • //Kibar titreşim - 0, 100, 1000, 300, 200, 100, 500, 200, 100
  • //Uygulama bildirimi - 0, 300, 400, 300
  • //Uzun titreşim - telefon araması - 100, 1000, 1000, 1000, 1000, 1000
  • //Star Wars Imperial March (Darth Vader's Theme) - 0, 500, 110, 500, 110, 450, 110, 200, 110, 170, 40, 450, 110, 200, 110, 170, 40, 500
Bu makaleyi paylaşın:

3 Comments

Bir yorum bırakın