Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8123895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:18:21+00:00 2026-06-06T06:18:21+00:00

I would like to bring up a Toast and vibrate when call status is

  • 0

I would like to bring up a Toast and vibrate when call status is Idle.
I added this in the manifest file:

<receiver android:name="IncomingCallInterceptor"> 
      <intent-filter> 
         <action android:name="android.intent.action.PHONE_STATE"/> 
      </intent-filter> 
    </receiver>

And this is IncomingCallInterceptor

import android.content.BroadcastReceiver; 
import android.content.Context;
import android.content.Intent;
import android.os.Vibrator;
import android.telephony.TelephonyManager;
 import android.widget.Toast;
 import android.app.Activity;



public class IncomingCallInterceptor extends BroadcastReceiver { 
     @Override
    public void onReceive(Context context, Intent intent)
    {                                        
        String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);                        
        String msg = "Phone state changed to " + state;

        if (TelephonyManager.EXTRA_STATE_RINGING.equals(state))
       {                                  
            String incomingNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
            msg += ". Incoming number is " + incomingNumber;


        }

        Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
        if(msg == "IDLE")
        {
          ok() ;
    }

    }
    public void ok() 
    { 


        Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
        v.vibrate(3000);
    }
     }
}

And I received this error:

Description Resource    Path    Location    Type
The method getSystemService(String) is undefined for the type IncomingCallInterceptor   IncomingCallInterceptor.java        line 39 Java Problem
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:18:22+00:00Added an answer on June 6, 2026 at 6:18 am

    Make Sure You Have Added VIBRATE permission in manifest as:

    <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="...">
        <uses-permission android:name="android.permission.VIBRATE"/>
        <application android:label="...">
            ...
        </application>
    </manifest>
    

    change Your Code as:

    public class IncomingCallInterceptor extends BroadcastReceiver { 
    private Context contextc;
     @Override
    public void onReceive(Context context, Intent intent)
    {                             
    this.contextc=context;
    //YOUR CODE HERE
    
    public void ok() 
    { 
        Vibrator v = (Vibrator)contextc.getSystemService(Context.VIBRATOR_SERVICE);
        v.vibrate(3000);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay I have this cool script I would like to bring to life, it
I would like to bring up the Camera in my app, and let the
I need to fire of a bunch of threads and would like to bring
I would like a home button on all my actives so they can bring
I am developing a skin where I would like to bring in the login
I have couple of ideas in my brain which I would like to bring
I have some simple UITextFields that bring up the Numberpad. I would like to
I am creating a stored procedure where I would like to bring back just
I'm using Intent(context, destinationClass) to switch activities. However, I would like to bring some
I would like to display a status window in my C# Windows Forms application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.