本文整理匯總了Java中android.app.NotificationManager.IMPORTANCE_UNSPECIFIED屬性的典型用法代碼示例。如果您正苦於以下問題:Java NotificationManager.IMPORTANCE_UNSPECIFIED屬性的具體用法?Java NotificationManager.IMPORTANCE_UNSPECIFIED怎麽用?Java NotificationManager.IMPORTANCE_UNSPECIFIED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.app.NotificationManager
的用法示例。
在下文中一共展示了NotificationManager.IMPORTANCE_UNSPECIFIED屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
@Override
public void onCreate(){
if(DEBUG) Log.i(TAG,"Service Started");
proximitySensorDetails = new ProximitySensorDetails(this);
IntentFilter screenStateFilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
screenStateFilter.addAction(Intent.ACTION_SCREEN_OFF);
registerReceiver(screenStateReceiver, screenStateFilter);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL, "BlueBolt Pocket Mode", NotificationManager.IMPORTANCE_UNSPECIFIED);
notificationManager.createNotificationChannel(notificationChannel);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, SplashActivity.class), 0);
Notification.Builder builder = new Notification.Builder(this, CHANNEL);
builder.setContentTitle(notificationTitle)
.setContentText(notificationText)
.setSmallIcon(R.mipmap.ic_launcher_foreground)
.setContentIntent(pendingIntent)
.setOngoing(true);
if(DEBUG) Log.i(TAG,"Notification Created");
startForeground(1, builder.build());
}
}