Search in sources :

Example 51 with RequiresApi

use of androidx.annotation.RequiresApi in project streaming-android by red5pro.

the class SubscribeService method createNotificationChannel.

@RequiresApi(Build.VERSION_CODES.O)
private String createNotificationChannel(String channelId, String channelName) {
    NotificationChannel chan = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_NONE);
    chan.setLightColor(Color.BLUE);
    chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
    NotificationManager service = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    service.createNotificationChannel(chan);
    return channelId;
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationManager(android.app.NotificationManager) RequiresApi(androidx.annotation.RequiresApi)

Example 52 with RequiresApi

use of androidx.annotation.RequiresApi in project react-native-push-notification by zo0r.

the class RNPushNotificationHelper method getDeliveredNotifications.

@RequiresApi(api = Build.VERSION_CODES.M)
public WritableArray getDeliveredNotifications() {
    WritableArray result = Arguments.createArray();
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        return result;
    }
    NotificationManager notificationManager = notificationManager();
    StatusBarNotification[] delivered = notificationManager.getActiveNotifications();
    Log.i(LOG_TAG, "Found " + delivered.length + " delivered notifications");
    /*
        * stay consistent to the return structure in
        * https://facebook.github.io/react-native/docs/pushnotificationios.html#getdeliverednotifications
        * but there is no such thing as a 'userInfo'
        */
    for (StatusBarNotification notification : delivered) {
        Notification original = notification.getNotification();
        Bundle extras = original.extras;
        WritableMap notif = Arguments.createMap();
        notif.putString("identifier", "" + notification.getId());
        notif.putString("title", extras.getString(Notification.EXTRA_TITLE));
        notif.putString("body", extras.getString(Notification.EXTRA_TEXT));
        notif.putString("tag", notification.getTag());
        notif.putString("group", original.getGroup());
        result.pushMap(notif);
    }
    return result;
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) NotificationManager(android.app.NotificationManager) StatusBarNotification(android.service.notification.StatusBarNotification) WritableArray(com.facebook.react.bridge.WritableArray) Bundle(android.os.Bundle) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification) RequiresApi(androidx.annotation.RequiresApi)

Example 53 with RequiresApi

use of androidx.annotation.RequiresApi in project collect by opendatakit.

the class FixedDatePickerDialog method onCreateDialog.

@RequiresApi(api = Build.VERSION_CODES.N)
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
    DatePickerDialog dialog = new DatePickerDialog(requireActivity(), viewModel.getDialogTheme(), viewModel.getDateSetListener(), viewModel.getLocalDateTime().getYear(), viewModel.getLocalDateTime().getMonthOfYear() - 1, viewModel.getLocalDateTime().getDayOfMonth());
    if (themeUtils.isSpinnerDatePickerDialogTheme(viewModel.getDialogTheme())) {
        dialog.setTitle(requireContext().getString(R.string.select_date));
        fixSpinner(requireContext(), dialog, viewModel.getLocalDateTime().getYear(), viewModel.getLocalDateTime().getMonthOfYear() - 1, viewModel.getLocalDateTime().getDayOfMonth());
        hidePickersIfNeeded(dialog, viewModel.getLocalDateTime());
        // noinspection deprecation
        dialog.getDatePicker().setCalendarViewShown(false);
    }
    return dialog;
}
Also used : DatePickerDialog(android.app.DatePickerDialog) NonNull(androidx.annotation.NonNull) RequiresApi(androidx.annotation.RequiresApi)

Example 54 with RequiresApi

use of androidx.annotation.RequiresApi in project ExoPlayer by google.

the class MediaCodecInfo method isAudioChannelCountSupportedV21.

/**
 * Whether the decoder supports audio with a given channel count.
 *
 * <p>Must not be called if the device SDK version is less than 21.
 *
 * @param channelCount The channel count.
 * @return Whether the decoder supports audio with the given channel count.
 */
@RequiresApi(21)
public boolean isAudioChannelCountSupportedV21(int channelCount) {
    if (capabilities == null) {
        logNoSupport("channelCount.caps");
        return false;
    }
    AudioCapabilities audioCapabilities = capabilities.getAudioCapabilities();
    if (audioCapabilities == null) {
        logNoSupport("channelCount.aCaps");
        return false;
    }
    int maxInputChannelCount = adjustMaxInputChannelCount(name, mimeType, audioCapabilities.getMaxInputChannelCount());
    if (maxInputChannelCount < channelCount) {
        logNoSupport("channelCount.support, " + channelCount);
        return false;
    }
    return true;
}
Also used : AudioCapabilities(android.media.MediaCodecInfo.AudioCapabilities) Point(android.graphics.Point) RequiresApi(androidx.annotation.RequiresApi)

Example 55 with RequiresApi

use of androidx.annotation.RequiresApi in project ExoPlayer by google.

the class RequirementsWatcher method registerNetworkCallbackV24.

@RequiresApi(24)
private void registerNetworkCallbackV24() {
    ConnectivityManager connectivityManager = checkNotNull((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE));
    networkCallback = new NetworkCallback();
    connectivityManager.registerDefaultNetworkCallback(networkCallback);
}
Also used : ConnectivityManager(android.net.ConnectivityManager) 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