Search in sources :

Example 66 with RequiresApi

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);
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationManager(android.app.NotificationManager) RequiresApi(android.support.annotation.RequiresApi)

Example 67 with RequiresApi

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: ");
}
Also used : Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification) RequiresApi(android.support.annotation.RequiresApi)

Example 68 with RequiresApi

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();
    }
}
Also used : Location(wangdaye.com.geometricweather.data.entity.model.Location) RequiresApi(android.support.annotation.RequiresApi)

Example 69 with RequiresApi

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);
    }
}
Also used : NotificationChannel(android.app.NotificationChannel) RequiresApi(android.support.annotation.RequiresApi)

Example 70 with RequiresApi

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);
}
Also used : NotificationChannel(android.app.NotificationChannel) NotificationManager(android.app.NotificationManager) AudioAttributes(android.media.AudioAttributes) RequiresApi(android.support.annotation.RequiresApi)

Aggregations

RequiresApi (android.support.annotation.RequiresApi)191 Intent (android.content.Intent)30 NotificationChannel (android.app.NotificationChannel)28 View (android.view.View)25 NotificationManager (android.app.NotificationManager)17 ViewGroup (android.view.ViewGroup)15 Allocation (android.renderscript.Allocation)14 Bitmap (android.graphics.Bitmap)13 RecyclerView (android.support.v7.widget.RecyclerView)13 ViewTreeObserver (android.view.ViewTreeObserver)12 WindowInsets (android.view.WindowInsets)12 TextView (android.widget.TextView)12 ActionBar (android.support.v7.app.ActionBar)11 Toolbar (android.support.v7.widget.Toolbar)11 Handler (android.os.Handler)10 StatFs (android.os.StatFs)9 Button (android.widget.Button)8 Cipher (javax.crypto.Cipher)8 SuppressLint (android.annotation.SuppressLint)7 Uri (android.net.Uri)7