chitikenasatis
Lurker
I am trying to handle incoming call automatically .
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 any ware i am wrong
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();
}
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 any ware i am wrong
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();
}