I have been banging my head against the table with this problem for 3 days now, please tell me where I have strayed.
When I am getting an incoming VoIP call, I am trying to show a full screen notification, just like the PhoneApp does. I am ok with heads up, if the user is in an immersive activity. However, I am getting only a heads up notification, and never getting a full screen. I need to notification to ignore the lock screen as well.
Here is what I am doing:
String callJson = call.toJson(uber).toString();
uber.requestWakeState(UberVoice.WAKE_STATE_FULL);
final Notification.Builder builder = new Notification.Builder(uber);
builder.setSmallIcon(R.drawable.switch_notification);
if (image != null) {
builder.setLargeIcon(image);
}
builder.setOngoing(true);
PendingIntent inCallPendingIntent =
PendingIntent.getActivity(uber, 234,
UberVoice.createInCallIntent(), 0);
builder.setContentIntent(inCallPendingIntent);
builder.setContentText(body);
builder.setUsesChronometer(false);
builder.setContentTitle(title);
builder.setCategory(Notification.CATEGORY_CALL);
builder.setVisibility(Notification.VISIBILITY_PUBLIC);
builder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE), AudioManager.STREAM_RING);
builder.setVibrate(new long[]{500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500});
builder.setPriority(Notification.PRIORITY_MAX);
builder.setTicker(title);
builder.setFullScreenIntent(inCallPendingIntent, true);
builder.addAction(R.drawable.hangup_action, "Reject", CallService.getPendingIntent(uber, callJson, CallService.REJECT));
builder.addAction(R.drawable.answer_action, "Answer", CallService.getPendingIntent(uber, callJson, CallService.ANSWER));
NotificationManager notificationManager = (NotificationManager) uber.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = builder.build();
notificationManager.notify(INCOMING_CALL_NOTIFICATION_ID, notification);
Here is the createInCallIntent code:
public static Intent createInCallIntent() {
Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
| Intent.FLAG_ACTIVITY_NO_USER_ACTION);
intent.setClassName("<package>", IncomingCallActivity.class.getName());
return intent;
}
And here is the IncomingCallActivity.onCreate()
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int flags = WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON;
getWindow().addFlags(flags);
setContentView(R.layout.activity_incoming_call);
I have tried starting this activity directly(uber is Application reference)
Intent incomingCallIntent = new Intent(uber, IncomingCallActivity.class);
String callJson = call.toJson(uber).toString();
incomingCallIntent.putExtra("call", callJson);
incomingCallIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
uber.startActivity(incomingCallIntent);
What am I doing wrong?
INCOMING_CALL_NOTIFICATION_ID
is already active,fullScreenIntent
for the new notification will be ignored. Could this be the problem you're dealing with? – ThorstennotificationManager.cancel(INCOMING_CALL_NOTIFICATION_ID)
right beforenotificationManager.notify(INCOMING_CALL_NOTIFICATION_ID, notification)
. – Thorsten