Reputation: 1
I have to start call activity from background when someone calls. I have tried this code but it's not working. Notification is not come and no error exists. What mistake I had made.
Intent fullScreenIntent = new Intent(conn, IncCallActivity.class);
fullScreenIntent.putExtra("name", callerName);
fullScreenIntent.putExtra("out", false);
fullScreenIntent.putExtra("channel_id", channelId);
fullScreenIntent.putExtra("id", callerId);
PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(conn, 112,fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Uri sound = Uri.parse(((AppBack) getApplication()).shared().getString("ringU", "no"));
NotificationManager notificationManager =(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel mChannel = notificationManager.getNotificationChannel("VIDEO_CALL");
AudioAttributes attributes = new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.setUsage(AudioAttributes.USAGE_ALARM)
.build();
if (mChannel == null) {
mChannel = new NotificationChannel("VIDEO_CALL", "VIDEO_CALL",NotificationManager.IMPORTANCE_HIGH);
mChannel.setSound(sound, attributes);
notificationManager.createNotificationChannel(mChannel);
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(conn, " VIDEO_CALL").setSmallIcon(R.drawable.logo)
.setContentTitle("Incoming call")
.setContentText("Call from " + callFrom)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setCategory(NotificationCompat.CATEGORY_CALL)
.setContentIntent(fullScreenPendingIntent)
.setFullScreenIntent(fullScreenPendingIntent, true)
.setAutoCancel(true)
.setOngoing(true);
Notification notification = builder.build();
notificationManager.notify(120, notification);
Upvotes: 0
Views: 669
Reputation: 31
I think you should add permission to AndroidManifest.xml
.
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
Upvotes: 1