I have a broadcast receiver that listens to incoming calls. And I want to tweak the incoming call screen. Right now I can present toasts and add notifications to the notific
Up to Android 2.3 you can not override the calling screen, but you can show a Toast message on it. The longest period of a toast is 3 seconds and after that it will dissapear. You can however create a thread that calls show() method of the toast every 2 seconds. Something like that:
Thread t = new Thread() {
public void run() {
try {
while (true) {
if( isInCall ){
toast.cancel();
break;
}
toast.show();
sleep(1850);
}
} catch (Exception e) {
Log.d("Exception: " + e.toString());
}
}
};
t.start();
You have to declare toast:
private Toast toast;
You have to init the toast object befor showing it.
toast = new Toast(getBaseContext());
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.toast, null, false);
toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);