Is it possible to vibrate from broadcast receiver during incoming call

0 votes

Android Native Devlopment

I try to create custom vibration of incoming call:

I am running a foreground service to avoid the user from setting phone state to vibration in order to take control of the Vibrator during incoming call but it failed.

public class CallsReceiver extends BroadcastReceiver {

    public void onReceive(Context context, Intent intent) {
        if (state.equals(TelephonyManager.EXTRA_STATE_RINGING)) {
            AudioManager am = (AudioManager) context.getSystemService(context.AUDIO_SERVICE);
            long[] VIBRATE_PATTERN = {500,500,500,500,500,500,500,500};
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            // API 26 and above
            } else {
                // Below API 26
                mVibrator.vibrate(VIBRATE_PATTERN, -1);

I have already tried to run the vibration in new thread and run it from service but no success. I did a research and I realized that on new android api levels, the code in broadcast receiver runs with low priority so I tried to run a schedule job -> service with higher priority and I got the same result.

there are few time that a little short vibrate starts but it stops after that

Apr 22, 2020 in Others by APK
• 120 points

1 answer to this question.

0 votes

Hello Android Native Development

I have found some related suggestions for your query on the internet. You may watch out these preferred links by myself:  


The above mentioned links include a web page which will give a certain nearest possible outcome for your query, and the second link includes a Youtube video which is also similar.

answered May 9, 2020 by Anadya

Related Questions In Others

0 votes
2 answers

What is white box testing and how is it different from black box testing?

Black Box Testing is a software testing method in ...READ MORE

answered Feb 20, 2019 in Others by preetiagarwal
• 170 points
0 votes
1 answer

What is a name function in JavaScript & how to define it?

A named function declares a name as ...READ MORE

answered Mar 6, 2019 in Others by Frankie
• 9,810 points
0 votes
1 answer
0 votes
2 answers
0 votes
1 answer

How to check if array is multidimensional or not?

Since the 'second dimension' could be just ...READ MORE

answered Nov 5, 2018 in Others by DataKing99
• 8,240 points
0 votes
1 answer

How is machine learning used to detect objects?

To understand the surrounding environment in real ...READ MORE

answered Nov 30, 2018 in Others by Kailash
+3 votes
3 answers
0 votes
1 answer

How can we get the current location in Android?

First you need to define a LocationListener to handle ...READ MORE

answered Sep 25, 2018 in Java by Parth
• 4,630 points
0 votes
1 answer

Can't find class CognitoUserPoolsSignInProvider: Issue with Sign In integration

CognitoUserPoolsSignInProvider is ditributed as part of aws-android-sdk-auth-userpools library. Please import ...READ MORE

answered Sep 28, 2018 in AWS by Priyaj
• 58,140 points