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
0 answers

How is it possible for DynamoDB to support both Key-Value and Document database properties at the same time

As per DynamoDB's documentation, it supports both ...READ MORE

Apr 5 in Others by Kichu
• 19,040 points
0 votes
0 answers

Is it possible to open developer tools console in Chrome on Android phone?

Is it possible to open JS console ...READ MORE

Jun 14 in Others by nisha
• 2,190 points
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 7, 2019 in Others by Frankie
• 9,830 points
0 votes
1 answer
0 votes
2 answers
+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,080 points
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP