Notification shown on receiving call not showing


i have added a broadcast receiver that responds to incoming call and the following is the code of the broadcast receiver onreceive method

Bundle extras=intent.getExtras(); if(extras!=null) { String state=extras.getString(TelephonyManager.EXTRA_STATE); System.out.println(state); if(state.equals(TelephonyManager.CALL_STATE_RINGING)) { String phoneno=extras.getString(TelephonyManager.EXTRA_INCOMING_NUMBER); Toast.makeText(context, "proper", Toast.LENGTH_SHORT).show(); System.out.println("no is "+phoneno); NotificationManager nm=(NotificationManager)context.getSystemService(context.NOTIFICATION_SERVICE); Notification nt=new Notification(R.drawable.ic_launcher, "You got call", System.currentTimeMillis()+2000); String title="You got call"; String text="The call you got was from "+phoneno; Intent ii=new Intent(""); //ii.setData(Uri.parse("http://www.google.com")); PendingIntent pi=PendingIntent.getActivity(context, 1, ii, 0); nt.setLatestEventInfo(context, title, text, pi); nm.notify(5, nt); Toast.makeText(context, "proper", Toast.LENGTH_SHORT).show(); } }

however when i send a call from the ddms ,the notification does not show.a log message if added does show in the verbose.kindly update why this is happening. thanks tejinder


This is my code which is working

I think that you need to write


public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras(); if(null == bundle) return; Log.i("IncomingCallReceiver",bundle.toString()); String state = bundle.getString(TelephonyManager.EXTRA_STATE); Log.i("IncomingCallReceiver","State: "+ state); if(state.equalsIgnoreCase(TelephonyManager.EXTRA_STATE_RINGING)) { String phonenumber = bundle.getString(TelephonyManager.EXTRA_INCOMING_NUMBER); Log.i("IncomingCallReceiver","Incomng Number: " + phonenumber); String info = "Detect Calls sample application\nIncoming number: " + phonenumber; Toast.makeText(context, info, Toast.LENGTH_LONG).show(); } }


  • Cannot Send data Through pendingIntent
  • Android notification manager update percentage
  • Notification in all devices
  • App it not doing…anything?
  • Android Inside Custom ListView, TextView Weight property not working
  • How to solve error “Unable to start activity ComponentInfo”?
  • How to get notification count in android?
  • Get Result from onPostExecute inner AsyncTask to OnCreate
  • Android Change image on click, custom expandable list adapter
  • Why git pull --rebase results a forced update?
  • Is it possible to wait until a toast has finished to resume the method?
  • Android: what is the difference between Fragment !isDetached() and isAdded()?
  • Android Multiple Instances
  • Incorrect timestamp on future notifications
  • Change Background Color of Clicked Child in Expandable ListView Android outside the onChildClick() m
  • Firebase fcm token not generating
  • Group ID being ignored when creating NotificationChannel
  • pyspark streaming restore from checkpoint
  • Notification Icon showing white on lollipop and above devices
  • get details of source repository from Jenkinsfile
  • How to open pdf file in external app or in webview size is greater than 25mb
  • Android Service…application crashes when making a Toast
  • Android: Transfering Data via ContentIntent
  • Titanium - Perform Action when user clicks on Android Notification
  • Can weak symbol be resolved among libraries during linking?
  • Android sensor listener does not get unregistered or sensor still retrieves values
  • Push notifications don't work
  • AlarmManager is blocking main thread
  • Why is my AlarmManager firing off instantly?
  • onLeScan never gets called android
  • android.app.PendingIntent cannot be accessed ouside the package
  • FCM Data messages are not working properly
  • Missing permission to control media error on Android 5/L
  • Check if a string to interpolate provides expected placeholders
  • javascript inside java/jsp code
  • Sending data from AppleScript to FileMaker records
  • KeystoneJS: Relationships in Admin UI not updating
  • AngularJs get employee from factory
  • Load html files in TinyMce