android-vibration

How to access vibrator in android in a class that is not extending activity?

倖福魔咒の 提交于 2019-12-13 04:29:47
问题 I'm trying to access the vibrator using the following in class called VibrationManager and the class is not extending Activity Vibrator v =(Vibrator) getSystemService(Context.VIBRATOR_SERVICE); but eclipse throws and error like The method getSystemService(String) is undefined for the type VibrationManager This is my whole Class public class VibrationManager { private static VibrationManager me = null; Vibrator v = null; private Vibrator getVibrator(){ if(v == null){ v = (Vibrator)

Vibrator In Android, Stopping when the app exits

余生长醉 提交于 2019-12-11 23:56:14
问题 I am basically developing an Applicatin which requires the App to Vibrate just before it closes down. Now when I call the vibrator.vibrate() function and then call the finish() function, the Vibration is stopped and the app is exited, before the Vibration completes. I want the app to wait until the vibration gets over and then exit! Thanks in Advance! 回答1: I think you need set a duration for vibration for this purpose given links can help you Can you increase vibrator strength on android

Varying vibration intensity: how does the VIBE app do it?

僤鯓⒐⒋嵵緔 提交于 2019-12-11 15:39:23
问题 I understand that, given how vibration is achieved, the only way to vary the intensity would be a way to control the RPM of the motor. I can see the Vibrator Class does not allow for this, and yet, the VIBE app (see this video) appears to be achieving just that. On the video, at about 0:35, the "create your own vibe" is briefly shown. I tested it and, by god, it appears to be varying the intensity. Could it be that they are using the NDK for direct motor control? 回答1: ViBe uses the Immersion

How to Call Vibrator inside a Service in android

Deadly 提交于 2019-12-11 08:22:49
问题 I am trying to run the vibrator if service is called from my app.I am starting the service from Fragment but i don't know why vibrator is not working inside the service.I couldn't even print the Toast .My code: Calling from Fragment: Intent buzz= new Intent(getActivity(),LocBuzzService.class); getActivity().startService(buzz); Service class: public class LocBuzzService extends Service { private static final String TAG = "HelloService"; private boolean isRunning = false; public Vibrator

Android Emulator Vibration Test? [duplicate]

↘锁芯ラ 提交于 2019-12-10 12:39:44
问题 This question already has an answer here : Debug Android vibration (1 answer) Closed last year . Is there a way to test vibrations on the Virtual Devices that come with Android Studio? I tried searching logcat and it seems like there isn't any indication of when the Android device is vibrating or not. 回答1: Did you try this? logcat -b system (Look into this answer: Debug Android vibration) Othere than that, if you are writing the code, the vibration is called with the method Vibrator.vibrate()

How to add vibration to cocos2d-x 3.2 on Android and iOS devices?

余生长醉 提交于 2019-12-08 07:54:50
问题 I want to vibrate my device in one of my slider functionality, using cocos2d-x 3.2. I followed some of reference links regarding this on the official forums but I'm still stumped. Can anyone help me? 回答1: After Searching a lot , Finally i am done with my Vibrate Function in Cocos2d-x 3.2 for android. There is one Vibrator Class. Vibrator.h #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include <jni.h> #include <android/log.h> #include "platform/android/jni/JniHelper.h" #endif #define CLASS

How to turn off vibration of Notifications in android

懵懂的女人 提交于 2019-12-06 15:37:30
I'm developing an app that handles sound and vibration of apps' notifications . I am listening to notifications using NotificationListenerService . I am able to turn on or off notification's sound using AudioManager as follows: // It turns off notification's sound myAudioManager.setStreamMute(AudioManager.STREAM_NOTIFICATION, true); // It turns on notification's sound myAudioManager.setStreamMute(AudioManager.STREAM_NOTIFICATION, false); I have also tried to turn on or off notification's vibration with following code but it didn't work on my phone which has Android KitKat 4.4.4 // to turn off

how to change ringer mode in background(Vibrate or Silent)

耗尽温柔 提交于 2019-12-06 11:24:16
I'm trying to write a program in which user can set time that will change ringer mode to vibrate or normal in background. When I set the start time it's working but at the end time it's not changing and device continuing vibrate mode. I just want, at the start time phone would be in vibrate and at end time phone would go back into the silent mode. MainActivity.java public class MainActivity extends Activity { private PendingIntent pendingIntent; private AlarmManager alarmManager; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R

vibrate_when_ringing on Android Marshmallow (6.0)

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 07:02:34
问题 In my code I have: Settings.System.putInt(this.getContentResolver(), "vibrate_when_ringing", isVibrateWhenRinging ? 1 :0); Using the following permission: <uses-permission android:name="android.permission.WRITE_SETTINGS" /> This was working fine from Jelly Bean (API 16) till Lollipop (API 22). In Android M, I know that for using that permission I need to prompt the user to Settings.ACTION_MANAGE_WRITE_SETTINGS. However, even with that permission turned on, I see the following error: E

How to trigger Vibration on Sound Input?

两盒软妹~` 提交于 2019-12-05 03:33:21
I am trying to create an android application where I filter one specific frequency of a beep and make the phone vibrate. I am taking input from the MIC of mobile and using MediaRecorder class, by using this class, I can record, save and play the input. Now I need my mobile to vibrate whenever there is a beep/or any sound. The input is given by a wire to the Headphone jack of the mobile so I know that there is only one frequency being input. I have a button, Clicking which starts recording. I have Permissions to vibrate and record in my manifest file already. record.setOnClickListener(new View