本文整理汇总了Java中android.app.NotificationChannel.enableVibration方法的典型用法代码示例。如果您正苦于以下问题:Java NotificationChannel.enableVibration方法的具体用法?Java NotificationChannel.enableVibration怎么用?Java NotificationChannel.enableVibration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.NotificationChannel
的用法示例。
在下文中一共展示了NotificationChannel.enableVibration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: CreateChannel
import android.app.NotificationChannel; //导入方法依赖的package包/类
public static void CreateChannel(String identifier, String name, String description, int importance, String soundName, int enableLights, int lightColor, int enableVibration, long[] vibrationPattern, String bundle) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
return;
channels.add(identifier);
NotificationManager nm = (NotificationManager) UnityPlayer.currentActivity.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channel = new NotificationChannel(identifier, name, importance);
channel.setDescription(description);
if (soundName != null) {
Resources res = UnityPlayer.currentActivity.getResources();
int id = res.getIdentifier("raw/" + soundName, null, UnityPlayer.currentActivity.getPackageName());
AudioAttributes audioAttributes = new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_NOTIFICATION).setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION).build();
channel.setSound(Uri.parse("android.resource://" + bundle + "/" + id), audioAttributes);
}
channel.enableLights(enableLights == 1);
channel.setLightColor(lightColor);
channel.enableVibration(enableVibration == 1);
if (vibrationPattern == null)
vibrationPattern = new long[] { 1000L, 1000L };
channel.setVibrationPattern(vibrationPattern);
nm.createNotificationChannel(channel);
}
示例2: createMainNotificationChannel
import android.app.NotificationChannel; //导入方法依赖的package包/类
@RequiresApi(Build.VERSION_CODES.O)
public void createMainNotificationChannel(Context c) {
String id = CHANNEL_ID;
String name = CHANNEL_NAME;
String description = CHANNEL_DESCRIPTION;
int importance = NotificationManager.IMPORTANCE_LOW;
NotificationChannel mChannel = new NotificationChannel(id, name, importance);
mChannel.setDescription (description);
mChannel.enableLights(true);
mChannel.setLightColor( Color.RED);
mChannel.enableVibration(true);
NotificationManager mNotificationManager =
(NotificationManager) c.getSystemService(Context.NOTIFICATION_SERVICE);
// NotificationManager mNotificationManager = c.getSystemService(Context.NOTIFICATION_SERVICE) as android.app.NotificationManager
mNotificationManager.createNotificationChannel(mChannel);
}
示例3: getNotificationChannelID
import android.app.NotificationChannel; //导入方法依赖的package包/类
private String getNotificationChannelID() {
final String channelID = "GoalieChannelID";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence name = getString(R.string.app_name);
String description = getString(R.string.channel_description);
int importance = NotificationManager.IMPORTANCE_HIGH;
NotificationChannel mChannel = new NotificationChannel(channelID, name, importance);
mChannel.setDescription(description);
mChannel.enableLights(true);
mChannel.enableVibration(true);
mNotificationManager.createNotificationChannel(mChannel);
}
return channelID;
}
示例4: createNotificationChannel
import android.app.NotificationChannel; //导入方法依赖的package包/类
private void createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
String id = Constants.NOTIFICATION_CHANNEL_ID;
CharSequence name = getString(R.string.notification_channel_name);
String desc = getString(R.string.notification_channel_desc);
int importance = NotificationManager.IMPORTANCE_LOW;
NotificationChannel channel = new NotificationChannel(id, name, importance);
channel.setShowBadge(false);
channel.setDescription(desc);
channel.enableLights(false);
channel.enableVibration(false);
manager.createNotificationChannel(channel);
}
}
示例5: createNotificationChannel
import android.app.NotificationChannel; //导入方法依赖的package包/类
public static String createNotificationChannel(@NonNull final Context context) {
final NotificationManager notificationManager = context.getSystemService(NotificationManager.class);
if (notificationManager == null) {
return "";
}
final NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_LOW);
channel.setDescription(CHANNEL_DESCRIPTION);
channel.enableLights(false);
channel.enableVibration(false);
channel.setBypassDnd(false);
channel.setShowBadge(false);
channel.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
notificationManager.createNotificationChannel(channel);
return CHANNEL_ID;
}
示例6: openChannel
import android.app.NotificationChannel; //导入方法依赖的package包/类
/**
* Creates the {@link NotificationChannel} for devices running Android O or higher
*/
private void openChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, mContext.getResources().getString(R.string.notification_channel_playback), android.app.NotificationManager.IMPORTANCE_LOW);
// Disable lights & vibration
channel.enableVibration(false);
channel.enableLights(false);
channel.setVibrationPattern(null);
// Allow lockscreen playback control
channel.setLockscreenVisibility(android.support.v4.app.NotificationCompat.VISIBILITY_PUBLIC);
// Register the channel
mNotificationManager.createNotificationChannel(channel);
}
}
示例7: NotificationUtils
import android.app.NotificationChannel; //导入方法依赖的package包/类
public NotificationUtils(Context context)
{
mContext = context;
mManager = NotificationManagerCompat.from(context);
mDatabase = new AccessDatabase(context);
mPreferences = PreferenceManager.getDefaultSharedPreferences(mContext);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel channelHigh = new NotificationChannel(NOTIFICATION_CHANNEL_HIGH, mContext.getString(R.string.text_appName), NotificationManager.IMPORTANCE_HIGH);
channelHigh.enableLights(mPreferences.getBoolean("notification_light", false));
channelHigh.enableVibration(mPreferences.getBoolean("notification_vibrate", false));
notificationManager.createNotificationChannel(channelHigh);
NotificationChannel channelLow = new NotificationChannel(NOTIFICATION_CHANNEL_LOW, mContext.getString(R.string.text_appName), NotificationManager.IMPORTANCE_NONE);
notificationManager.createNotificationChannel(channelLow);
}
}
示例8: createNotificationChannels
import android.app.NotificationChannel; //导入方法依赖的package包/类
/**
* Create notification channels required for displayal of notifications on >=API O
*/
@RequiresApi(api = Build.VERSION_CODES.O)
public static void createNotificationChannels(Context context) {
NotificationManager mNotificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
String channelId = ApplicationConstants.MEDIA_NOTIFICATION_CHANNEL_ID;
CharSequence userVisibleChannelName = context.getString(R.string.media_notification_channel_name);
String userVisibleDescription = context.getString(R.string.media_notification_channel_description);
int notificationImportance = NotificationManager.IMPORTANCE_DEFAULT;
AudioAttributes audioAttributes =
new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_MUSIC).build();
NotificationChannel mediaNotificationChannel = new NotificationChannel(channelId, userVisibleChannelName, notificationImportance);
mediaNotificationChannel.setDescription(userVisibleDescription);
mediaNotificationChannel.enableVibration(false);
mediaNotificationChannel.enableLights(false);
mediaNotificationChannel.setSound(Uri.EMPTY, audioAttributes);
mNotificationManager.createNotificationChannel(mediaNotificationChannel);
}
示例9: initDefaultChannel
import android.app.NotificationChannel; //导入方法依赖的package包/类
private void initDefaultChannel() {
if (Build.VERSION.SDK_INT < 26) {
return;
}
final NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager == null) {
return;
}
final CharSequence channelName = SoftwareInformation.getAppName(context);
final int importance = NotificationManager.IMPORTANCE_DEFAULT;
final NotificationChannel notificationChannel = new NotificationChannel(MM_DEFAULT_CHANNEL_ID, channelName, importance);
notificationChannel.enableLights(true);
notificationChannel.enableVibration(true);
notificationManager.createNotificationChannel(notificationChannel);
}
示例10: createchannel
import android.app.NotificationChannel; //导入方法依赖的package包/类
private void createchannel() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel mChannel = new NotificationChannel(getString(R.string.default_notification_channel_id),
getString(R.string.channel_name), //name of the channel
NotificationManager.IMPORTANCE_DEFAULT); //importance level
//important level: default is is high on the phone. high is urgent on the phone. low is medium, so none is low?
// Configure the notification channel.
mChannel.setDescription(getString(R.string.channel_description));
mChannel.enableLights(true);
//Sets the notification light color for notifications posted to this channel, if the device supports this feature.
mChannel.setLightColor(Color.RED);
mChannel.enableVibration(true);
mChannel.setShowBadge(true);
mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
nm.createNotificationChannel(mChannel);
}
}
示例11: onCreate
import android.app.NotificationChannel; //导入方法依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
CharSequence name = getString(R.string.channel_name_eta);
String description = getString(R.string.channel_description_eta);
NotificationChannel channel = new NotificationChannel(C.NOTIFICATION.CHANNEL_ETA, name, NotificationManager.IMPORTANCE_HIGH);
channel.setDescription(description);
channel.enableLights(false);
channel.enableVibration(false);
notificationManager.createNotificationChannel(channel);
}
disposables.add(RxBroadcastReceiver.create(this, new IntentFilter(C.ACTION.ETA_UPDATE))
.share()
.subscribeWith(etaObserver()));
}
示例12: createDefaultNotificationChannelIfNeeded
import android.app.NotificationChannel; //导入方法依赖的package包/类
@TargetApi(26)
private void createDefaultNotificationChannelIfNeeded(JSONObject options) {
// only call on Android O and above
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
final NotificationManager notificationManager = (NotificationManager) cordova.getActivity()
.getSystemService(Context.NOTIFICATION_SERVICE);
List<NotificationChannel> channels = notificationManager.getNotificationChannels();
if (channels.size() == 0) {
NotificationChannel mChannel = new NotificationChannel(DEFAULT_CHANNEL_ID, "PhoneGap PushPlugin",
NotificationManager.IMPORTANCE_DEFAULT);
mChannel.enableVibration(options.optBoolean(VIBRATE, true));
mChannel.setShowBadge(true);
notificationManager.createNotificationChannel(mChannel);
}
}
}
示例13: createChannels
import android.app.NotificationChannel; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.O)
public void createChannels() {
NotificationChannel launchImminent = new NotificationChannel(CHANNEL_LAUNCH_IMMINENT,
CHANNEL_LAUNCH_IMMINENT_NAME, NotificationManager.IMPORTANCE_HIGH);
launchImminent.enableLights(true);
launchImminent.setLightColor(ContextCompat.getColor(this, R.color.primary));
launchImminent.setShowBadge(true);
launchImminent.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
getManager().createNotificationChannel(launchImminent);
NotificationChannel statusChanged = new NotificationChannel(CHANNEL_LAUNCH_UPDATE,
CHANNEL_LAUNCH_UPDATE_NAME, NotificationManager.IMPORTANCE_DEFAULT);
statusChanged.enableLights(false);
statusChanged.enableVibration(true);
statusChanged.setLightColor(Color.RED);
statusChanged.setShowBadge(true);
getManager().createNotificationChannel(statusChanged);
}
示例14: createchannel
import android.app.NotificationChannel; //导入方法依赖的package包/类
private void createchannel() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationChannel mChannel = new NotificationChannel(id,
getString(R.string.channel_name), //name of the channel
NotificationManager.IMPORTANCE_DEFAULT); //importance level
//important level: default is is high on the phone. high is urgent on the phone. low is medium, so none is low?
// Configure the notification channel.
mChannel.setDescription(getString(R.string.channel_description));
mChannel.enableLights(true);
// Sets the notification light color for notifications posted to this channel, if the device supports this feature.
mChannel.setLightColor(Color.RED);
mChannel.enableVibration(true);
mChannel.setShowBadge(true);
mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
nm.createNotificationChannel(mChannel);
}
}
示例15: createchannel
import android.app.NotificationChannel; //导入方法依赖的package包/类
private void createchannel() {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationChannel mChannel = new NotificationChannel(id,
getString(R.string.channel_name), //name of the channel
NotificationManager.IMPORTANCE_DEFAULT); //importance level
//important level: default is is high on the phone. high is urgent on the phone. low is medium, so none is low?
// Configure the notification channel.
mChannel.setDescription(getString(R.string.channel_description));
mChannel.enableLights(true);
// Sets the notification light color for notifications posted to this channel, if the device supports this feature.
mChannel.setLightColor(Color.RED);
mChannel.enableVibration(true);
mChannel.setShowBadge(true);
mChannel.setVibrationPattern(new long[]{100, 200, 300, 400, 500, 400, 300, 200, 400});
nm.createNotificationChannel(mChannel);
}
}