I am trying to handle incoming calls automatically through BroadCast Receiver. Here is the sample code with BroadCastReceiver onRecive implementation. It is able to get a handle to incoming calls and making it silent but not able to send predefined voice or mp3 songs to caller . Please correct me if some thing wrong .. it picks the call automatically but caller able to listen conversation instead of audio or song .
public void onReceive(Context context, Intent intent) { Log.v(TAG, "WE ARE INSIDE!!!!satish satish satish satish !!!!!!!"); TelephonyManager telephony = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); AudioManager audomanager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); // context.getSystemService(Context.) try { Class c = Class.forName(telephony.getClass().getName()); Method m = c.getDeclaredMethod("getITelephony"); m.setAccessible(true); telephonyService = (ITelephony) m.invoke(telephony); Toast tag = Toast.makeText(context, "Call is not allowed in the meeting!!!", Toast.LENGTH_LONG); tag.setDuration(25); tag.show(); telephonyService.silenceRinger(); telephonyService.answerRingingCall(); Intent newintent = new Intent(android.content.Intent.ACTION_VIEW); //intent.setAction(android.content.Intent.ACTION_ANSWER); Uri data = Uri.parse("file:///sdcard/song.mp3"); String type = "audio/mp3"; newintent.setDataAndType(data, type); context.startActivity(newintent); //telephonyService.silenceRinger(); //telephonyService.endCall(); } catch (Exception e) { e.printStackTrace(); } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en