use of androidx.core.app.NotificationManagerCompat in project quickstart-android by firebase.
the class FunctionsMessagingService method onMessageReceived.
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
createNotificationChannel();
// Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data payload: " + remoteMessage.getData());
NotificationManagerCompat manager = NotificationManagerCompat.from(this);
Notification notification = new NotificationCompat.Builder(this, "Messages").setContentText(remoteMessage.getData().get("text")).setContentTitle("New message").setSmallIcon(R.drawable.ic_stat_notification).build();
manager.notify(0, notification);
}
}
use of androidx.core.app.NotificationManagerCompat in project IITB-App by wncc.
the class InstiAppFirebaseMessagingService method showNotification.
/**
* Show the notification
*/
private static void showNotification(Context context, int id, Notification notification) {
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.notify(id, notification);
}
use of androidx.core.app.NotificationManagerCompat in project Gadgetbridge by Freeyourgadget.
the class GB method createNotificationChannels.
public static void createNotificationChannels(Context context) {
if (notificationChannelsCreated)
return;
if (isRunningOreoOrLater()) {
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
NotificationChannel channelGeneral = new NotificationChannel(NOTIFICATION_CHANNEL_ID, context.getString(R.string.notification_channel_name), NotificationManager.IMPORTANCE_LOW);
notificationManager.createNotificationChannel(channelGeneral);
NotificationChannel channelHighPriority = new NotificationChannel(NOTIFICATION_CHANNEL_HIGH_PRIORITY_ID, context.getString(R.string.notification_channel_high_priority_name), NotificationManager.IMPORTANCE_HIGH);
notificationManager.createNotificationChannel(channelHighPriority);
NotificationChannel channelTransfer = new NotificationChannel(NOTIFICATION_CHANNEL_ID_TRANSFER, context.getString(R.string.notification_channel_transfer_name), NotificationManager.IMPORTANCE_LOW);
notificationManager.createNotificationChannel(channelTransfer);
NotificationChannel channelLowBattery = new NotificationChannel(NOTIFICATION_CHANNEL_ID_LOW_BATTERY, context.getString(R.string.notification_channel_low_battery_name), NotificationManager.IMPORTANCE_DEFAULT);
notificationManager.createNotificationChannel(channelLowBattery);
}
notificationChannelsCreated = true;
}
use of androidx.core.app.NotificationManagerCompat in project fdroidclient by f-droid.
the class HidingManager method removeNotifications.
private static void removeNotifications(Context context) {
NotificationManagerCompat nm = NotificationManagerCompat.from(context);
nm.cancelAll();
}
use of androidx.core.app.NotificationManagerCompat in project Applozic-Android-SDK by AppLozic.
the class MobiComConversationFragment method loadConversation.
public void loadConversation(final Contact contact, final Channel channel, final Integer conversationId, final String searchString) {
try {
if (downloadConversation != null) {
downloadConversation.cancel(true);
}
if (this.contact != null && contact != null && !contact.getUserId().equals(this.contact.getUserId())) {
userDisplayName = null;
}
setContact(contact);
setChannel(channel);
BroadcastService.currentUserId = contact != null ? contact.getContactIds() : String.valueOf(channel.getKey());
typingStarted = false;
onSelected = false;
messageMetaData = null;
Applozic.subscribeToTyping(getContext(), channel, contact);
checkForUserNotAbleToChatAndToggleViews(contact, channel);
if (contact != null && this.channel != null) {
if (getActivity() != null) {
setToolbarSubtitle("");
setToolbarImage(contact, channel);
}
if (menu != null) {
menu.findItem(R.id.unmuteGroup).setVisible(false);
menu.findItem(R.id.muteGroup).setVisible(false);
}
}
if (replayRelativeLayout != null) {
replayRelativeLayout.setVisibility(View.GONE);
}
if (TextUtils.isEmpty(filePath) && attachmentLayout != null) {
attachmentLayout.setVisibility(View.GONE);
}
if (!TextUtils.isEmpty(defaultText) && messageEditText != null) {
messageEditText.setText(defaultText);
defaultText = "";
}
extendedSendingOptionLayout.setVisibility(VISIBLE);
unregisterForContextMenu(recyclerView);
if (getActivity() != null) {
if (ApplozicClient.getInstance(getActivity()).isNotificationStacking()) {
NotificationManagerCompat nMgr = NotificationManagerCompat.from(getActivity());
nMgr.cancel(NotificationService.NOTIFICATION_ID);
} else {
if (contact != null) {
if (!TextUtils.isEmpty(contact.getContactIds())) {
NotificationManager notificationManager = (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null) {
notificationManager.cancel(contact.getContactIds().hashCode());
}
}
}
if (channel != null) {
NotificationManager notificationManager = (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null) {
notificationManager.cancel(String.valueOf(channel.getKey()).hashCode());
}
}
}
}
clearList();
updateTitle(contact, channel);
swipeLayout.setEnabled(true);
loadMore = true;
if (selfDestructMessageSpinner != null) {
selfDestructMessageSpinner.setSelection(0);
}
if (contact != null) {
recyclerDetailConversationAdapter = new DetailedConversationAdapter(getActivity(), messageList, contact, messageIntentClass, emojiIconHandler);
recyclerDetailConversationAdapter.setAlCustomizationSettings(alCustomizationSettings);
recyclerDetailConversationAdapter.setRichMessageCallbackListener(richMessageActionProcessor.getRichMessageListener());
recyclerDetailConversationAdapter.setContextMenuClickListener(this);
recyclerDetailConversationAdapter.setSendMessageInterfaceCallBack(this);
if (getActivity() instanceof ALStoragePermissionListener) {
recyclerDetailConversationAdapter.setStoragePermissionListener((ALStoragePermissionListener) getActivity());
} else {
recyclerDetailConversationAdapter.setStoragePermissionListener(new ALStoragePermissionListener() {
@Override
public boolean isPermissionGranted() {
return false;
}
@Override
public void checkPermission(ALStoragePermission storagePermission) {
}
});
}
} else if (channel != null) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
if (!ChannelService.getInstance(getContext()).isUserAlreadyPresentInChannel(channel.getKey(), loggedInUserId) && messageTemplate != null && messageTemplate.isEnabled() && templateAdapter != null) {
if (getActivity() == null) {
return;
}
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
templateAdapter.removeTemplates();
}
});
}
}
});
thread.setPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
recyclerDetailConversationAdapter = new DetailedConversationAdapter(getActivity(), messageList, channel, messageIntentClass, emojiIconHandler);
recyclerDetailConversationAdapter.setAlCustomizationSettings(alCustomizationSettings);
recyclerDetailConversationAdapter.setContextMenuClickListener(this);
recyclerDetailConversationAdapter.setSendMessageInterfaceCallBack(this);
recyclerDetailConversationAdapter.setRichMessageCallbackListener(richMessageActionProcessor.getRichMessageListener());
if (getActivity() instanceof ALStoragePermissionListener) {
recyclerDetailConversationAdapter.setStoragePermissionListener((ALStoragePermissionListener) getActivity());
} else {
recyclerDetailConversationAdapter.setStoragePermissionListener(new ALStoragePermissionListener() {
@Override
public boolean isPermissionGranted() {
return false;
}
@Override
public void checkPermission(ALStoragePermission storagePermission) {
}
});
}
}
linearLayoutManager.setSmoothScrollbarEnabled(true);
if (getActivity() == null) {
return;
}
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
linearLayoutManager.setStackFromEnd(true);
}
});
recyclerView.setAdapter(recyclerDetailConversationAdapter);
registerForContextMenu(recyclerView);
processMobiTexterUserCheck();
downloadConversation = new DownloadConversation(recyclerView, true, 1, 0, 0, contact, channel, conversationId);
AlTask.execute(downloadConversation);
if (hideExtendedSendingOptionLayout) {
extendedSendingOptionLayout.setVisibility(View.GONE);
}
emoticonsFrameLayout.setVisibility(View.GONE);
MobiComConversationService mobiComConversationService = new MobiComConversationService(requireContext().getApplicationContext());
if (contact != null) {
mobiComConversationService.syncUserDetail(contact.getUserId());
}
if (channel != null) {
if (Channel.GroupType.GROUPOFTWO.getValue().equals(channel.getType())) {
String userId = ChannelService.getInstance(getActivity()).getGroupOfTwoReceiverUserId(channel.getKey());
if (!TextUtils.isEmpty(userId)) {
mobiComConversationService.syncUserDetail(userId);
}
} else {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
updateChannelSubTitle(channel);
}
});
thread.setPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
}
}
if (alCustomizationSettings.isMessageFastScrollEnabled()) {
if (getActivity() == null) {
return;
}
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
recyclerView.smoothScrollToPosition(messageList.size());
recyclerView.getLayoutManager().scrollToPosition(messageList.size());
}
});
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations