Search in sources :

Example 46 with RequiresApi

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());
        }
    }
}
Also used : Context(android.content.Context) NotificationManager(android.app.NotificationManager) NotificationCompat(androidx.core.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.app.TaskStackBuilder) RequiresApi(androidx.annotation.RequiresApi)

Example 47 with RequiresApi

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);
}
Also used : NotificationManager(android.app.NotificationManager) Bundle(android.os.Bundle) TaskStackBuilder(android.app.TaskStackBuilder) NotificationManagerCompat(androidx.core.app.NotificationManagerCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification) NotificationChannel(android.app.NotificationChannel) NotificationCompat(androidx.core.app.NotificationCompat) PendingIntent(android.app.PendingIntent) TaskStackBuilder(android.app.TaskStackBuilder) RequiresApi(androidx.annotation.RequiresApi)

Example 48 with RequiresApi

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;
}
Also used : Intent(android.content.Intent) NonNull(androidx.annotation.NonNull) RequiresApi(androidx.annotation.RequiresApi)

Example 49 with RequiresApi

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;
}
Also used : Rect(android.graphics.Rect) RequiresApi(androidx.annotation.RequiresApi)

Example 50 with RequiresApi

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;
}
Also used : Rect(android.graphics.Rect) RequiresApi(androidx.annotation.RequiresApi)

Aggregations

RequiresApi (androidx.annotation.RequiresApi)117 NotificationChannel (android.app.NotificationChannel)16 Intent (android.content.Intent)13 SuppressLint (android.annotation.SuppressLint)10 NotificationManager (android.app.NotificationManager)9 Uri (android.net.Uri)9 StatusBarNotification (android.service.notification.StatusBarNotification)9 NonNull (androidx.annotation.NonNull)9 IOException (java.io.IOException)8 Notification (android.app.Notification)6 PendingIntent (android.app.PendingIntent)6 Context (android.content.Context)6 ObjectAnimator (android.animation.ObjectAnimator)5 Bundle (android.os.Bundle)5 ByteBuffer (java.nio.ByteBuffer)5 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)5 SecretKey (javax.crypto.SecretKey)5 GestureDescription (android.accessibilityservice.GestureDescription)4 TaskStackBuilder (android.app.TaskStackBuilder)4 Bitmap (android.graphics.Bitmap)4