Hi,
i have written code to start services on receiving calls,
here is my code,
*/
public class CallHelper {
/**
* Listener to detect incoming calls.
*/
private class CallStateListener extends PhoneStateListener implements
OnInitListener{
@Override
public void onCallStateChanged(int state, String incomingNumber) {
boolean entered=false;
switch (state) {
case TelephonyManager.CALL_STATE_RINGING:
// called when someone is ringing to this phone
String text="";
Log.v("Test","entered"+incomingNumber);
Toast.makeText(ctx,
"Incoming: "+incomingNumber,
Toast.LENGTH_LONG).show();
// tts.setLanguage(Locale.US);
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
break;
}
}
public void onInit(int status) {
// TODO Auto-generated method stub
}
}
/**
* Broadcast receiver to detect the outgoing calls.
*/
public class OutgoingReceiver extends BroadcastReceiver implements
TextToSpeech.OnInitListener {
public TextToSpeech mTts;
public OutgoingReceiver() {
}
@Override
public void onReceive(Context context, Intent intent) {
}
public void onInit(int status) {
// TODO Auto-generated method stub
if (status == TextToSpeech.SUCCESS) {
if (mTts.isLanguageAvailable(Locale.UK) >= 0)
Toast.makeText( ctx,
"Sucessfull intialization of Text-To-Speech engine Mytell ",
Toast.LENGTH_LONG).show();
mTts.setLanguage(Locale.UK);
} else if (status == TextToSpeech.ERROR) {
Toast.makeText(ctx,
"Unable to initialize Text-To-Speech engine",
Toast.LENGTH_LONG).show();
}
}
}
private Context ctx;
private TelephonyManager tm;
private CallStateListener callStateListener;
private OutgoingReceiver outgoingReceiver;
public CallHelper(Context ctx) {
this.ctx = ctx;
callStateListener = new CallStateListener();
outgoingReceiver = new OutgoingReceiver();
}
/**
* Start calls detection.
*/
public void start() {
tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(callStateListener, PhoneStateListener.LISTEN_CALL_STATE);
IntentFilter intentFilter = new
IntentFilter(Intent.ACTION_NEW_OUTGOING_CALL);
ctx.registerReceiver(outgoingReceiver, intentFilter);
}
/**
* Stop calls detection.
*/
public void stop() {
tm.listen(callStateListener, PhoneStateListener.LISTEN_NONE);
ctx.unregisterReceiver(outgoingReceiver);
}
}
this code is showing the incoming no.
i want to stop the ringtone and start text to speech and say "hey boss u
have a call", or other text,
i have tried a lot but failed, even i faced the issue of bound error for
text to speech,
can any one make this and reply me the sample code please,
Thanks,
Shiva shankar,
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.