use of android.support.annotation.RequiresApi in project androidApp by InspectorIncognito.
the class OnBusService method createChannel.
@RequiresApi(Build.VERSION_CODES.O)
private void createChannel() {
NotificationManager mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
// The user-visible name of the channel.
CharSequence name = "Servicio en Bus";
// The user-visible description of the channel.
String description = "Control del estado 'en bus'";
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name, importance);
// Configure the notification channel.
mChannel.setDescription(description);
mChannel.setShowBadge(false);
mChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
mNotificationManager.createNotificationChannel(mChannel);
}
use of android.support.annotation.RequiresApi in project My-MVP by REBOOTERS.
the class MyService method onCreate.
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onCreate() {
super.onCreate();
Notification.Builder builer = new Notification.Builder(getApplicationContext());
builer.setSmallIcon(R.mipmap.ic_launcher).setContentTitle("有通知到来").setContentText(Tools.getCurrentTime());
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
Notification notification = builer.build();
builer.setContentIntent(pendingIntent);
startForeground(1, notification);
Log.e(TAG, "onCreate: ");
}
use of android.support.annotation.RequiresApi in project GeometricWeather by WangDaYeeeeee.
the class TileHelper method refreshTile.
/**
* <br> UI.
*/
@RequiresApi(api = Build.VERSION_CODES.N)
public static void refreshTile(Context context, Tile tile) {
if (tile == null) {
return;
}
Location location = DatabaseHelper.getInstance(context).readLocationList().get(0);
location.weather = DatabaseHelper.getInstance(context).readWeather(location);
if (location.weather != null) {
boolean f = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(context.getString(R.string.key_fahrenheit), false);
tile.setIcon(Icon.createWithResource(context, WeatherHelper.getNotificationWeatherIcon(location.weather.realTime.weatherKind, TimeManager.getInstance(context).isDayTime())));
tile.setLabel(ValueUtils.buildCurrentTemp(location.weather.realTime.temp, false, f));
tile.updateTile();
}
}
use of android.support.annotation.RequiresApi in project MusicLibrary by lizixian18.
the class CustomNotification method createNotificationChannel.
@RequiresApi(Build.VERSION_CODES.O)
private void createNotificationChannel() {
if (mNotificationManager.getNotificationChannel(CHANNEL_ID) == null) {
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, mService.getString(R.string.notification_channel), NotificationManager.IMPORTANCE_LOW);
notificationChannel.setDescription(mService.getString(R.string.notification_channel_description));
mNotificationManager.createNotificationChannel(notificationChannel);
}
}
use of android.support.annotation.RequiresApi in project ring-client-android by savoirfairelinux.
the class NotificationServiceImpl method registerNotificationChannels.
@RequiresApi(api = Build.VERSION_CODES.O)
private void registerNotificationChannels() {
NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager == null)
return;
// Call channel
NotificationChannel callChannel = new NotificationChannel(NOTIF_CHANNEL_CALL, mContext.getString(R.string.notif_channel_calls), NotificationManager.IMPORTANCE_HIGH);
callChannel.enableVibration(true);
callChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
notificationManager.createNotificationChannel(callChannel);
// Text messages channel
AudioAttributes soundAttributes = new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION).setUsage(AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_INSTANT).build();
NotificationChannel messageChannel = new NotificationChannel(NOTIF_CHANNEL_MESSAGE, mContext.getString(R.string.notif_channel_messages), NotificationManager.IMPORTANCE_HIGH);
messageChannel.enableVibration(true);
messageChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
messageChannel.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION), soundAttributes);
notificationManager.createNotificationChannel(messageChannel);
// Contact requests
NotificationChannel requestsChannel = new NotificationChannel(NOTIF_CHANNEL_REQUEST, mContext.getString(R.string.notif_channel_requests), NotificationManager.IMPORTANCE_DEFAULT);
requestsChannel.enableVibration(true);
requestsChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
requestsChannel.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION), soundAttributes);
notificationManager.createNotificationChannel(requestsChannel);
// File transfer requests
NotificationChannel fileTransferChannel = new NotificationChannel(NOTIF_CHANNEL_FILE_TRANSFER, mContext.getString(R.string.notif_channel_file_transfer), NotificationManager.IMPORTANCE_DEFAULT);
fileTransferChannel.enableVibration(true);
fileTransferChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
fileTransferChannel.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION), soundAttributes);
notificationManager.createNotificationChannel(fileTransferChannel);
}
Aggregations