use of android.app.NotificationChannel in project bitcoin-wallet by bitcoin-wallet.
the class WalletApplication method initNotificationManager.
private void initNotificationManager() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
final Stopwatch watch = Stopwatch.createStarted();
final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
final NotificationChannel received = new NotificationChannel(Constants.NOTIFICATION_CHANNEL_ID_RECEIVED, getString(R.string.notification_channel_received_name), NotificationManager.IMPORTANCE_DEFAULT);
received.setSound(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.coins_received), new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION).setLegacyStreamType(AudioManager.STREAM_NOTIFICATION).setUsage(AudioAttributes.USAGE_NOTIFICATION_EVENT).build());
nm.createNotificationChannel(received);
final NotificationChannel ongoing = new NotificationChannel(Constants.NOTIFICATION_CHANNEL_ID_ONGOING, getString(R.string.notification_channel_ongoing_name), NotificationManager.IMPORTANCE_LOW);
nm.createNotificationChannel(ongoing);
final NotificationChannel important = new NotificationChannel(Constants.NOTIFICATION_CHANNEL_ID_IMPORTANT, getString(R.string.notification_channel_important_name), NotificationManager.IMPORTANCE_HIGH);
nm.createNotificationChannel(important);
log.info("created notification channels, took {}", watch);
}
}
use of android.app.NotificationChannel in project aware-client by denzilferreira.
the class Aware method onCreate.
@Override
public void onCreate() {
super.onCreate();
AUTHORITY = Aware_Provider.getAuthority(this);
IntentFilter storage = new IntentFilter();
storage.addAction(Intent.ACTION_MEDIA_MOUNTED);
storage.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
storage.addDataScheme("file");
registerReceiver(storage_BR, storage);
IntentFilter boot = new IntentFilter();
boot.addAction(Intent.ACTION_BOOT_COMPLETED);
boot.addAction(Intent.ACTION_SHUTDOWN);
boot.addAction(Intent.ACTION_REBOOT);
boot.addAction(Intent.ACTION_BATTERY_CHANGED);
registerReceiver(awareBoot, boot);
IntentFilter awareActions = new IntentFilter();
awareActions.addAction(Aware.ACTION_AWARE_SYNC_DATA);
awareActions.addAction(Aware.ACTION_QUIT_STUDY);
registerReceiver(aware_BR, awareActions);
IntentFilter foreground = new IntentFilter();
foreground.addAction(Aware.ACTION_AWARE_PRIORITY_FOREGROUND);
foreground.addAction(Aware.ACTION_AWARE_PRIORITY_BACKGROUND);
registerReceiver(foregroundMgr, foreground);
IntentFilter scheduler = new IntentFilter();
scheduler.addAction(Intent.ACTION_TIME_TICK);
schedulerTicker.interval_ms = 60000 * getApplicationContext().getResources().getInteger(R.integer.alarm_wakeup_interval_min);
registerReceiver(schedulerTicker, scheduler);
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
stopSelf();
return;
}
// Android 8 specific: create a notification channel for AWARE
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager not_manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotificationChannel aware_channel = new NotificationChannel(AWARE_NOTIFICATION_ID, getResources().getString(R.string.app_name), NotificationManager.IMPORTANCE_DEFAULT);
aware_channel.setDescription(getResources().getString(R.string.aware_description));
aware_channel.enableLights(true);
aware_channel.setLightColor(Color.BLUE);
aware_channel.enableVibration(true);
not_manager.createNotificationChannel(aware_channel);
}
// Start the foreground service only if it's the client or a standalone application
if ((getApplicationContext().getPackageName().equals("com.aware.phone") || getApplicationContext().getApplicationContext().getResources().getBoolean(R.bool.standalone)))
getApplicationContext().sendBroadcast(new Intent(Aware.ACTION_AWARE_PRIORITY_FOREGROUND));
if (Aware.DEBUG)
Log.d(TAG, "AWARE framework is created!");
IS_CORE_RUNNING = true;
aware_account = getAWAREAccount(this);
}
Aggregations