use of androidx.annotation.RequiresApi in project android-beacon-library by AltBeacon.
the class BluetoothMedic method sendScreenNotification.
@RequiresApi(21)
private void sendScreenNotification(String message, String detail) {
Context context = mContext;
if (context == null) {
LogManager.e(TAG, "congtext is unexpectedly null");
return;
}
initializeWithContext(context);
if (this.mNotificationsEnabled) {
if (!this.mNotificationChannelCreated) {
createNotificationChannel(context, "err");
}
NotificationCompat.Builder builder = (new NotificationCompat.Builder(context, "err")).setContentTitle("BluetoothMedic: " + message).setSmallIcon(mNotificationIcon).setVibrate(new long[] { 200L, 100L, 200L }).setContentText(detail);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addNextIntent(new Intent("NoOperation"));
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
builder.setContentIntent(resultPendingIntent);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null) {
notificationManager.notify(1, builder.build());
}
}
}
use of androidx.annotation.RequiresApi in project zype-android by zype.
the class PlayerService method createNotificationChannel.
@RequiresApi(Build.VERSION_CODES.O)
private void createNotificationChannel(String channelId, String channelName, String videoTitle, String videoId, MediaSessionCompat.Token mediaSessionToken, Boolean isPlay) {
Intent resultIntent = new Intent(this, VideoDetailActivity.class);
Bundle bundle = new Bundle();
bundle.putString(BundleConstants.VIDEO_ID, videoId);
resultIntent.putExtras(bundle);
resultIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
// Create the TaskStackBuilder and add the intent, which inflates the back stack
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
stackBuilder.addNextIntentWithParentStack(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationChannel chan = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_DEFAULT);
chan.enableVibration(false);
chan.setSound(null, null);
chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
assert manager != null;
manager.createNotificationChannel(chan);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId);
notificationBuilder.setContentIntent(resultPendingIntent).setContentTitle(this.getString(R.string.app_name)).setContentText(videoTitle).setSmallIcon(R.drawable.ic_background_playback).setPriority(NotificationCompat.PRIORITY_MAX).setCategory(Notification.CATEGORY_SERVICE).setAutoCancel(true).setOngoing(true).setWhen(0);
if (isPlay) {
notificationBuilder.addAction(new NotificationCompat.Action(R.drawable.ic_pause_black_24dp, "Pause", MediaButtonReceiver.buildMediaButtonPendingIntent(this, PlaybackStateCompat.ACTION_PLAY_PAUSE)));
} else {
notificationBuilder.addAction(new NotificationCompat.Action(R.drawable.ic_play_arrow_black_24dp, "Play", MediaButtonReceiver.buildMediaButtonPendingIntent(this, PlaybackStateCompat.ACTION_PLAY_PAUSE)));
}
notificationBuilder.setStyle(new androidx.media.app.NotificationCompat.MediaStyle().setMediaSession(mediaSessionToken).setShowCancelButton(true).setCancelButtonIntent(MediaButtonReceiver.buildMediaButtonPendingIntent(this, PlaybackStateCompat.ACTION_STOP)));
Notification notification = notificationBuilder.build();
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.notify(ZypeApp.NOTIFICATION_ID, notificationBuilder.build());
startForeground(ZypeApp.NOTIFICATION_ID, notification);
}
use of androidx.annotation.RequiresApi in project J2ME-Loader by nikita36078.
the class SAFFileResultContract method createIntent.
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@NonNull
@Override
public Intent createIntent(@NonNull Context context, String input) {
Intent i = new Intent(Intent.ACTION_OPEN_DOCUMENT);
i.setType("*/*");
i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
return i;
}
use of androidx.annotation.RequiresApi in project EhViewer by seven332.
the class GalleryHeader method getOffsetLeft.
@RequiresApi(api = Build.VERSION_CODES.P)
private int getOffsetLeft(Rect rect, View view, int width) {
int offset = 0;
measureChild(rect, view, width, 0, 0);
rect.offset(lastX, lastY);
for (Rect notch : displayCutout.getBoundingRects()) {
if (Rect.intersects(notch, rect)) {
offset = Math.max(offset, notch.right - lastX);
}
}
return offset;
}
use of androidx.annotation.RequiresApi in project EhViewer by seven332.
the class GalleryHeader method getOffsetRight.
@RequiresApi(api = Build.VERSION_CODES.P)
private int getOffsetRight(Rect rect, View view, int width) {
int offset = 0;
measureChild(rect, view, width, 0, 0);
rect.offset(lastX, lastY);
for (Rect notch : displayCutout.getBoundingRects()) {
if (Rect.intersects(notch, rect)) {
offset = Math.max(offset, lastX + width - notch.left);
}
}
return offset;
}
Aggregations