use of android.app.NotificationChannel in project Etar-Calendar by Etar-Group.
the class AlertService method createChannels.
public static void createChannels(Context context) {
if (Utils.isOreoOrLater()) {
// Create notification channel
NotificationMgr nm = new NotificationMgrWrapper((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE));
NotificationChannel channel = new NotificationChannel(ALERT_CHANNEL_ID, context.getString(R.string.standalone_app_label), NotificationManager.IMPORTANCE_HIGH);
channel.enableLights(true);
NotificationChannel foregroundChannel = new NotificationChannel(FOREGROUND_CHANNEL_ID, context.getString(R.string.foreground_notification_channel_name), NotificationManager.IMPORTANCE_LOW);
foregroundChannel.setDescription(context.getString(R.string.foreground_notification_channel_description));
nm.createNotificationChannel(channel);
nm.createNotificationChannel(foregroundChannel);
}
}
use of android.app.NotificationChannel in project phonegap-plugin-push by phonegap.
the class PushPlugin method listChannels.
@TargetApi(26)
private JSONArray listChannels() throws JSONException {
JSONArray channels = new JSONArray();
// only call on Android O and above
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
final NotificationManager notificationManager = (NotificationManager) cordova.getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
List<NotificationChannel> notificationChannels = notificationManager.getNotificationChannels();
for (NotificationChannel notificationChannel : notificationChannels) {
JSONObject channel = new JSONObject();
channel.put(CHANNEL_ID, notificationChannel.getId());
channel.put(CHANNEL_DESCRIPTION, notificationChannel.getDescription());
channels.put(channel);
}
}
return channels;
}
use of android.app.NotificationChannel in project Signal-Android by WhisperSystems.
the class MainActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
if (Build.VERSION.SDK_INT > 26) {
NotificationChannel deviceTransfer = new NotificationChannel(TRANSFER_NOTIFICATION_CHANNEL, "Device Transfer", NotificationManager.IMPORTANCE_DEFAULT);
NotificationManagerCompat.from(this).createNotificationChannel(deviceTransfer);
}
list = findViewById(R.id.list);
final TransferNotificationData data = new TransferNotificationData(1337, TRANSFER_NOTIFICATION_CHANNEL, R.drawable.ic_refresh_20);
findViewById(R.id.start_server).setOnClickListener(v -> {
DeviceToDeviceTransferService.startServer(this, new ServerReceiveRandomBytes(), data, PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0));
list.removeAllViews();
});
findViewById(R.id.start_client).setOnClickListener(v -> {
DeviceToDeviceTransferService.startClient(this, new ClientSendRandomBytes(), data, PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0));
list.removeAllViews();
});
findViewById(R.id.stop).setOnClickListener(v -> DeviceToDeviceTransferService.stop(this));
findViewById(R.id.enable_permission).setOnClickListener(v -> {
if (Build.VERSION.SDK_INT >= 23 && checkSelfPermission(Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, 420);
}
});
EventBus.getDefault().register(this);
}
use of android.app.NotificationChannel in project Signal-Android by WhisperSystems.
the class NotificationChannels method createChannelFor.
/**
* More verbose version of {@link #createChannelFor(Context, Recipient)}.
*/
@Nullable
public static synchronized String createChannelFor(@NonNull Context context, @NonNull String channelId, @NonNull String displayName, @Nullable Uri messageSound, boolean vibrationEnabled, @Nullable String shortcutId) {
if (!supported()) {
return null;
}
NotificationChannel channel = new NotificationChannel(channelId, displayName, NotificationManager.IMPORTANCE_HIGH);
setLedPreference(channel, SignalStore.settings().getMessageLedColor());
channel.setGroup(CATEGORY_MESSAGES);
setVibrationEnabled(channel, vibrationEnabled);
if (messageSound != null) {
channel.setSound(messageSound, new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN).setUsage(AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_INSTANT).build());
}
if (Build.VERSION.SDK_INT >= CONVERSATION_SUPPORT_VERSION && shortcutId != null) {
channel.setConversationId(getMessagesChannel(context), shortcutId);
}
NotificationManager notificationManager = ServiceUtil.getNotificationManager(context);
notificationManager.createNotificationChannel(channel);
return channelId;
}
use of android.app.NotificationChannel in project Signal-Android by WhisperSystems.
the class NotificationChannels method isCallsChannelValid.
public static boolean isCallsChannelValid(@NonNull Context context) {
if (!supported()) {
return true;
}
NotificationManager notificationManager = ServiceUtil.getNotificationManager(context);
NotificationChannel channel = notificationManager.getNotificationChannel(CALLS);
return channel != null && channel.getImportance() == NotificationManager.IMPORTANCE_HIGH;
}
Aggregations