my code: [code]public static final String CHANNEL_ID_NOTIFICATION = "intercom_channel_id"; public static final String CHANNEL_ID_NEW_CALL = "intercom_channel_id_new_call";
private static final String CHANNEL_NAME = "My Channel"; private static final String CHANNEL_DESCRIPTION = "Channel for general notifications";
private static final int NOTIFICATION_ID_NOTIFICATION = 1; private static final int NOTIFICATION_ID_NEW_CALL = 2;
public static final String INTENT_ACTION_CALL_INCOMING = "tindroidx.intent.action.call.INCOMING"; public static final String INTENT_ACTION_CALL_CLOSE = "tindroidx.intent.action.call.CLOSE"; public static final String INTENT_EXTRA_TOPIC = "co.tinode.tindroid.TOPIC"; public static final String INTENT_EXTRA_SEQ = "co.tinode.tindroid.SEQ"; public static final String INTENT_EXTRA_CALL_DIRECTION = "co.tinode.tindroid.CALL_DIRECTION"; public static final String INTENT_EXTRA_CALL_ACCEPTED = "co.tinode.tindroid.CALL_ACCEPTED"; public static final String INTENT_EXTRA_CALL_AUDIO_ONLY = "co.tinode.tindroid.CALL_AUDIO_ONLY";
private static PendingIntent declineIntent(Context context, String topicName, int seq) { final Intent intent = new Intent(context, PythonActivity.class); intent.setAction(INTENT_ACTION_CALL_CLOSE); intent.putExtra(INTENT_EXTRA_TOPIC, topicName); intent.putExtra(INTENT_EXTRA_SEQ, seq); return PendingIntent.getBroadcast(context, 103, intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE); }
public static void showNotificationNewCall(Context context, String title, String message) { Log.v(Settings.T(new Throwable(), new Object(){}), "");
try {
Person caller = new Person.Builder() .setName("Jane Doe") .setImportant(true) .build(); int seq = 0; boolean audioOnly = false;
// 2. Create an Intent for the activity to open when the notification is tapped Intent intent = new Intent(context, PythonActivity.class); // Replace PythonActivity.class with your desired activity intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); PendingIntent pendingIntent = PendingIntent.getActivity( context, 101, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE //PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE // Use FLAG_IMMUTABLE for security );
// 3. Build the Notification Notification.Builder builder = new Notification.Builder(context, CHANNEL_ID_NEW_CALL); builder.setSmallIcon(android.R.drawable.ic_dialog_info) // Replace with your own icon .setContentTitle(title) .setContentText(message) .setPriority(Notification.PRIORITY_HIGH) .setFullScreenIntent(pendingIntent, true) // Set the PendingIntent .setAutoCancel(true) // Dismisses the notification when tapped .setUsesChronometer(true) .setCategory(Notification.CATEGORY_CALL) //.setOngoing(true) .setContentIntent(pendingIntent) .setTimeoutAfter(30000) .setVisibility(Notification.VISIBILITY_PUBLIC);
// 4. Show the Notification NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); if (notificationManager != null) { notificationManager.notify(NOTIFICATION_ID_NEW_CALL, builder.build()); // Use a unique ID for each notification } } catch (Exception e) { Log.v(Settings.T(new Throwable(), new Object(){}), e.toString() + " " + e.getMessage()); } } [/code] Я использовал:
[*]https://www.forasoft.com/blog/article/how-to-make-a-custom-android-call-notification-455?ysclid=mffkcpnfca302281677,> />https://www.forasoft.com/blog/article/how-to-make-a-custom-android-call-notification-455? />https://github.com/tinode/tindroid/blob/1e0407db079d65be1603c92970def5d1c183125d/app/src/main/java/co/tinode/tindroid/callmanager.java#/Java/co/tinode/tindroid/callmanager.java#> /> Я не знаю, что делаю не так. < /p>
my code:
public static final String CHANNEL_ID_NOTIFICATION = intercom_channel_id ;
public static final String CHANNEL_ID_NEW_CALL = intercom_channel_id_new_call ;
Мне нужно создать приложение, которое сможет отклонять входящий вызов во время работы. Знаете ли вы решения для такого типа задач? Вероятно, это не сильно изменится, но я использую флаттер.
Я пытаюсь добавить CallScreeningService в свое приложение для Android (targetSdkVersion 29), не делая мое приложение приложением для звонков. Я следую всем инструкциям, но все равно не понимаю или что-то упускаю. Вот мой код:
Во время входящего звонка мое приложение переходит в фоновый режим, а экран телефона отображается в полноэкранном режиме (изображение 1). Я бы хотел, чтобы приложение было открыто, а окно телефонного звонка было свернуто внизу, как в Картах Google,...
Я хочу остановить уведомление Callkit во входящем вызове после отмены вызывающего абонента, и приемник еще не ответил, поэтому я получил, что пользователь отменил вызов с помощью другого уведомления Pushkit, у которого есть ключ без пропущенного....