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 {

    @Override
    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
            mVibrator.vibrate(VibrationEffect.createWaveform(VIBRATE_PATTERN,-1));
            } 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,655 views

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:

https://stackoverflow.com/questions/13950338/how-to-make-an-android-device-vibrate  

and

https://www.youtube.com/watch?v=N7IaCy5F2E4

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
1 answer

Is it possible to get data from a webpage in real-time to an excel file?

The conventional method of obtaining data from ...READ MORE

answered Jan 17, 2023 in Others by narikkadan
• 63,720 points
470 views
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, 2022 in Others by Kichu
• 19,050 points
715 views
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, 2022 in Others by nisha
• 2,210 points
1,443 views
0 votes
1 answer

MAX function in Excel: is it possible to provide the range by means of variables?

Try this: =MAX(INDEX(A:A,B2):INDEX(A:A,B3)) READ MORE

answered Nov 15, 2022 in Others by narikkadan
• 63,720 points
525 views
0 votes
1 answer

Is it possible to round to different decimal places in excel based on the range?

Where the range is multiple cells: Excel.Worksheet sheet ...READ MORE

answered Nov 17, 2022 in Others by narikkadan
• 63,720 points
646 views
0 votes
1 answer

Is it possible to see more than 65536 rows in Excel 2007?

Here is an interesting blog entry about the ...READ MORE

answered Dec 10, 2022 in Others by narikkadan
• 63,720 points
1,757 views
+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,640 points
885 views
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,100 points
878 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP