当前位置: 首页>>代码示例>>Java>>正文


Java Notification.DEFAULT_SOUND属性代码示例

本文整理汇总了Java中android.app.Notification.DEFAULT_SOUND属性的典型用法代码示例。如果您正苦于以下问题:Java Notification.DEFAULT_SOUND属性的具体用法?Java Notification.DEFAULT_SOUND怎么用?Java Notification.DEFAULT_SOUND使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.app.Notification的用法示例。


在下文中一共展示了Notification.DEFAULT_SOUND属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addCustomNotification

public void addCustomNotification(Intent onClickIntent, int iconResourceID, String title, String message, boolean isOngoingEvent) {
	PendingIntent notifContentIntent = PendingIntent.getActivity(this, 0, onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
	
	Bitmap bm = null;
	try {
		bm = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
	} catch (Exception e) {
	}
	mCustomNotif = Compatibility.createNotification(this, title, message, iconResourceID, 0, bm, notifContentIntent, isOngoingEvent,notifcationsPriority);
	
	mCustomNotif.defaults |= Notification.DEFAULT_VIBRATE;
	mCustomNotif.defaults |= Notification.DEFAULT_SOUND;
	mCustomNotif.defaults |= Notification.DEFAULT_LIGHTS;
	
	notifyWrapper(CUSTOM_NOTIF_ID, mCustomNotif);
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:16,代码来源:LinphoneService.java

示例2: showNotification

private void showNotification(String title, String message) {
    Intent notifyIntent = new Intent(this, MainActivity.class);
    notifyIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivities(this, 0,
            new Intent[] { notifyIntent }, PendingIntent.FLAG_UPDATE_CURRENT);
    Notification notification = new Notification.Builder(this)
            .setSmallIcon(android.R.drawable.ic_dialog_info)
            .setContentTitle(title)
            .setContentText(message)
            .setAutoCancel(true)
            .setContentIntent(pendingIntent)
            .build();
    notification.defaults |= Notification.DEFAULT_SOUND;
    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(1, notification);
}
 
开发者ID:bjaanes,项目名称:BeaconMqtt,代码行数:17,代码来源:BeaconApplication.java

示例3: makeNotification

private Notification makeNotification(PendingIntent pendingIntent, String title, String content, String tickerText,
                                      int iconId, boolean ring, boolean vibrate) {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setContentTitle(title)
            .setContentText(content)
            .setAutoCancel(true)
            .setContentIntent(pendingIntent)
            .setTicker(tickerText)
            .setSmallIcon(iconId);
    int defaults = Notification.DEFAULT_LIGHTS;
    if (vibrate) {
        defaults |= Notification.DEFAULT_VIBRATE;
    }
    if (ring) {
        defaults |= Notification.DEFAULT_SOUND;
    }
    builder.setDefaults(defaults);

    return builder.build();
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:20,代码来源:AVChatNotification.java

示例4: makeNotification

private Notification makeNotification(PendingIntent pendingIntent, String title, String content, String tickerText,
                                      int iconId, boolean ring, boolean vibrate) {
    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    builder.setContentTitle(title)
            .setContentText(content)
            .setTicker(content)
            .setAutoCancel(true)
            .setContentIntent(pendingIntent)
            .setTicker(tickerText)
            .setLargeIcon(largeIconId())
            .setSmallIcon(iconId);
    int defaults = Notification.DEFAULT_LIGHTS;
    if (vibrate) {
        defaults |= Notification.DEFAULT_VIBRATE;
    }
    if (ring) {
        defaults |= Notification.DEFAULT_SOUND;
    }
    builder.setDefaults(defaults);

    return builder.build();
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:22,代码来源:TeamAVChatNotification.java

示例5: testNotificationAdapter

@Test
public void testNotificationAdapter() {
    final String NOTIFICATION_TEXT = "adapter-text";
    final String NOTIFICATION_TITLE = "adapter-title";
    final long TIMEOUT = 5000;

    Context appContext = InstrumentationRegistry.getTargetContext();

    RemoteViews contentView = new RemoteViews("cn.dreamtobe.toolset.test", R.layout.custom_layout);
    contentView.setTextViewText(R.id.title, NOTIFICATION_TITLE);
    contentView.setTextViewText(R.id.text, NOTIFICATION_TEXT);

    // Fix the Notification-Style problem ---------------
    // Set the default title style color to title view.
    contentView.setTextColor(R.id.title, NotificationAdapter.getTitleColor(appContext));
    // Set the default title style size to title view
    contentView.setTextViewTextSize(R.id.title, COMPLEX_UNIT_PX, NotificationAdapter.getTitleSize(appContext));
    // Set the default text style color to text view
    contentView.setTextColor(R.id.text, NotificationAdapter.getTextColor(appContext));
    // Set the default text style size to text view
    contentView.setTextViewTextSize(R.id.text, COMPLEX_UNIT_PX, NotificationAdapter.getTextSize(appContext));
    // End fix the Notification-Style problem ---------------

    Notification notification = new Notification();
    notification.icon = R.drawable.ic_launcher;
    notification.contentView = contentView;

    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.defaults |= Notification.DEFAULT_SOUND;
    notification.defaults |= Notification.DEFAULT_VIBRATE;

    NotificationManager notifyMgr =
            (NotificationManager) appContext.getSystemService(NOTIFICATION_SERVICE);
    notifyMgr.notify(1, notification);

    UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
    device.openNotification();
    device.wait(Until.hasObject(By.text(NOTIFICATION_TITLE)), TIMEOUT);
}
 
开发者ID:Jacksgong,项目名称:notification-adapter,代码行数:39,代码来源:NotificationAdapterTest.java

示例6: showNotification

public static void showNotification(Context context, Intent intent, String title, String body, int drawableId)
 {
NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(drawableId, body, System.currentTimeMillis());
notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.defaults = Notification.DEFAULT_SOUND;
if (intent == null)
{
  // FIXEME: category tab is disabled
  //要是  intent = new Intent(context, FileViewActivity.class);
}
//  PendingIntent contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT);
//  notification.setLatestEventInfo(context, title, body, contentIntent);
manager.notify(drawableId, notification);
 }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:15,代码来源:Util.java

示例7: isPassiveNotification

private boolean isPassiveNotification(Notification notification) {
    // If notification specified either default vibration or default sound, mark it as non-passive
    if ((notification.defaults & (Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND)) != 0) {
        return false;
    }

    return getVibrationLength(notification.vibrate) == 0 && notification.sound == null;

}
 
开发者ID:matejdro,项目名称:WearVibrationCenter,代码行数:9,代码来源:NotificationProcessor.java

示例8: showMessage

/**
 * 通知栏提醒
 * @param messageItem 消息信息
 */
@SuppressWarnings("deprecation")
private void showMessage(ChatMessageItem messageItem) {
	SettingSPUtil setSP = MyApp.getInstance().getSettingSPUtil();
	if (!setSP.isChatNotiOnBar()){
		return;
	}
	String messageContent = messageItem.getNickName()+":"+messageItem.getMessage();
	MyApp.getInstance().setNewMsgCount(MyApp.getInstance().getNewMsgCount()+1); //数目+1
	Notification notification = new Notification(R.drawable.ic_launcher,messageContent, System.currentTimeMillis());
	notification.flags = Notification.FLAG_AUTO_CANCEL;
	if (setSP.isChatRing()){
		// 设置默认声音
		notification.defaults |= Notification.DEFAULT_SOUND;
	}
	if (setSP.isChatVibrate()){
		// 设定震动(需加VIBRATE权限)
		notification.defaults |= Notification.DEFAULT_VIBRATE;
	}
	Intent intent = new Intent(MyApp.getInstance(),ChatRoomAty.class);
	intent.putExtra("TrainId", messageItem.getTrainId());
	PendingIntent contentIntent = PendingIntent.getActivity(MyApp.getInstance(), 0, intent, 0);
	String contentText = null;
	if(MyApp.getInstance().getNewMsgCount()==1){
		contentText = messageContent;
	}else{
		contentText = MyApp.getInstance().getNewMsgCount()+"条未读消息";
	}
	
	notification.setLatestEventInfo(MyApp.getInstance(), "车友聊天室", contentText, contentIntent);
	NotificationManager manage = (NotificationManager) MyApp.getInstance().getSystemService(Context.NOTIFICATION_SERVICE);
	manage.notify(NOTIFICATION_ID, notification);
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:36,代码来源:PushMessageReceiver.java

示例9: setStyleBasic

/**
 * 设置通知提示方式 - 基础属性
 */
private void setStyleBasic() {
	BasicPushNotificationBuilder builder = new BasicPushNotificationBuilder(PushSetActivity.this);
	builder.statusBarDrawable = R.drawable.ic_launcher;
	builder.notificationFlags = Notification.FLAG_AUTO_CANCEL;  //设置为点击后自动消失
	builder.notificationDefaults = Notification.DEFAULT_SOUND;  //设置为铃声( Notification.DEFAULT_SOUND)或者震动( Notification.DEFAULT_VIBRATE)
	JPushInterface.setPushNotificationBuilder(1, builder);
	Toast.makeText(PushSetActivity.this, "Basic Builder - 1", Toast.LENGTH_SHORT).show();
}
 
开发者ID:LuoLuo0101,项目名称:JPush,代码行数:11,代码来源:PushSetActivity.java

示例10: setBuilder

/**
     * 设置builder的信息,在用大文本时会用到这个
     *
     * @param pendingIntent
     * @param smallIcon
     * @param ticker
     */
    private void setBuilder(PendingIntent pendingIntent, int smallIcon, String ticker, boolean sound, boolean vibrate, boolean lights) {
        nBuilder = new Notification.Builder(mContext);
        // 如果当前Activity启动在前台,则不开启新的Activity。
//        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
//        PendingIntent pIntent = PendingIntent.getActivity(mContext,
//                requestCode, intent, FLAG);
        nBuilder.setContentIntent(pendingIntent);

        nBuilder.setSmallIcon(smallIcon);


        nBuilder.setTicker(ticker);
        nBuilder.setWhen(System.currentTimeMillis());
        nBuilder.setPriority(Notification.PRIORITY_MAX);

        int defaults = 0;

        if (sound) {
            defaults |= Notification.DEFAULT_SOUND;
        }
        if (vibrate) {
            defaults |= Notification.DEFAULT_VIBRATE;
        }
        if (lights) {
            defaults |= Notification.DEFAULT_LIGHTS;
        }

        nBuilder.setDefaults(defaults);
    }
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:36,代码来源:NotifyUtil.java

示例11: setCompatBuilder

/**
     * 设置在顶部通知栏中的各种信息
     *
     * @param pendingIntent
     * @param smallIcon
     * @param ticker
     * @param pendingIntentCancel
     */
    private void setCompatBuilder(PendingIntent pendingIntent, int smallIcon, String ticker,
                                  String title, String content, boolean sound, boolean vibrate, boolean lights, PendingIntent pendingIntentCancel) {
//        // 如果当前Activity启动在前台,则不开启新的Activity。
//        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
//        // 当设置下面PendingIntent.FLAG_UPDATE_CURRENT这个参数的时候,常常使得点击通知栏没效果,你需要给notification设置一个独一无二的requestCode
//        // 将Intent封装进PendingIntent中,点击通知的消息后,就会启动对应的程序
//        PendingIntent pIntent = PendingIntent.getActivity(mContext,
//                requestCode, intent, FLAG);

        cBuilder.setContentIntent(pendingIntent);// 该通知要启动的Intent
        cBuilder.setSmallIcon(smallIcon);// 设置顶部状态栏的小图标
        cBuilder.setTicker(ticker);// 在顶部状态栏中的提示信息

        cBuilder.setContentTitle(title);// 设置通知中心的标题
        cBuilder.setContentText(content);// 设置通知中心中的内容
        cBuilder.setWhen(System.currentTimeMillis());


		/*
         * 将AutoCancel设为true后,当你点击通知栏的notification后,它会自动被取消消失,
		 * 不设置的话点击消息后也不清除,但可以滑动删除
		 */
        cBuilder.setAutoCancel(true);
        // 将Ongoing设为true 那么notification将不能滑动删除
        // notifyBuilder.setOngoing(true);
        /*
         * 从Android4.1开始,可以通过以下方法,设置notification的优先级,
		 * 优先级越高的,通知排的越靠前,优先级低的,不会在手机最顶部的状态栏显示图标
		 */
        cBuilder.setPriority(NotificationCompat.PRIORITY_MAX);
        /*
         * Notification.DEFAULT_ALL:铃声、闪光、震动均系统默认。
		 * Notification.DEFAULT_SOUND:系统默认铃声。
		 * Notification.DEFAULT_VIBRATE:系统默认震动。
		 * Notification.DEFAULT_LIGHTS:系统默认闪光。
		 * notifyBuilder.setDefaults(Notification.DEFAULT_ALL);
		 */
        int defaults = 0;

        cBuilder.setDeleteIntent(pendingIntentCancel);


        if (sound) {
            defaults |= Notification.DEFAULT_SOUND;
        }
        if (vibrate) {
            defaults |= Notification.DEFAULT_VIBRATE;
        }
        if (lights) {
            defaults |= Notification.DEFAULT_LIGHTS;
        }


        cBuilder.setDefaults(defaults);
    }
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:63,代码来源:Notify.java

示例12: setCompatBuilder

/**
     * 设置在顶部通知栏中的各种信息
     *  @param pendingIntent
     * @param smallIcon
     * @param ticker
     * @param pendingIntentCancel
     */
    private void setCompatBuilder(PendingIntent pendingIntent, int smallIcon, String ticker,
                                  String title, String content, boolean sound, boolean vibrate, boolean lights, PendingIntent pendingIntentCancel) {
//        // 如果当前Activity启动在前台,则不开启新的Activity。
//        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
//        // 当设置下面PendingIntent.FLAG_UPDATE_CURRENT这个参数的时候,常常使得点击通知栏没效果,你需要给notification设置一个独一无二的requestCode
//        // 将Intent封装进PendingIntent中,点击通知的消息后,就会启动对应的程序
//        PendingIntent pIntent = PendingIntent.getActivity(mContext,
//                requestCode, intent, FLAG);

        cBuilder.setContentIntent(pendingIntent);// 该通知要启动的Intent
        cBuilder.setSmallIcon(smallIcon);// 设置顶部状态栏的小图标
        cBuilder.setTicker(ticker);// 在顶部状态栏中的提示信息

        cBuilder.setContentTitle(title);// 设置通知中心的标题
        cBuilder.setContentText(content);// 设置通知中心中的内容
        cBuilder.setWhen(System.currentTimeMillis());

		/*
         * 将AutoCancel设为true后,当你点击通知栏的notification后,它会自动被取消消失,
		 * 不设置的话点击消息后也不清除,但可以滑动删除
		 */
        cBuilder.setAutoCancel(true);
        // 将Ongoing设为true 那么notification将不能滑动删除
        // notifyBuilder.setOngoing(true);
        /*
         * 从Android4.1开始,可以通过以下方法,设置notification的优先级,
		 * 优先级越高的,通知排的越靠前,优先级低的,不会在手机最顶部的状态栏显示图标
		 */
        cBuilder.setPriority(NotificationCompat.PRIORITY_MAX);
        /*
         * Notification.DEFAULT_ALL:铃声、闪光、震动均系统默认。
		 * Notification.DEFAULT_SOUND:系统默认铃声。
		 * Notification.DEFAULT_VIBRATE:系统默认震动。
		 * Notification.DEFAULT_LIGHTS:系统默认闪光。
		 * notifyBuilder.setDefaults(Notification.DEFAULT_ALL);
		 */
        int defaults = 0;

        cBuilder.setDeleteIntent(pendingIntentCancel);





        if (sound) {
            defaults |= Notification.DEFAULT_SOUND;
        }
        if (vibrate) {
            defaults |= Notification.DEFAULT_VIBRATE;
        }
        if (lights) {
            defaults |= Notification.DEFAULT_LIGHTS;
        }



        cBuilder.setDefaults(defaults);
    }
 
开发者ID:Justson,项目名称:AgentWebX5,代码行数:65,代码来源:Notify.java

示例13: createNotification

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
    @SuppressWarnings("deprecation")
    public static void createNotification(Context context, Class<?> cls, String title, String content, String ticker, int id){
        NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

        Intent detailIntent = context.getPackageManager().getLaunchIntentForPackage(CommonUtils
                .getPackageName(context));
        detailIntent.setPackage((String)null);
        detailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        PendingIntent pendingIntent2 = PendingIntent.getActivity(context, 0,
                detailIntent, 0);
        int smallicon = SharedPreferencesUtil.getIntData(context, ZhiChiConstant
                .SOBOT_NOTIFICATION_SMALL_ICON, ResourceUtils.getIdByName(context, "drawable", "sobot_logo_small_icon"));
        int largeicon = SharedPreferencesUtil.getIntData(context, ZhiChiConstant
                .SOBOT_NOTIFICATION_LARGE_ICON, ResourceUtils.getIdByName(context, "drawable", "sobot_logo_icon"));
        // 通过Notification.Builder来创建通知,注意API Level
        // API11之后才支持
//        int smallicon = ResourceUtils.getIdByName(context, "drawable", "sobot_logo_small_icon");
//        int largeicon = ResourceUtils.getIdByName(context, "drawable", "sobot_logo_icon");

        BitmapDrawable bd = (BitmapDrawable) context.getResources().getDrawable(largeicon);
        Bitmap bitmap = bd.getBitmap();
        Notification notify2 = new Notification.Builder(context)
                .setSmallIcon(smallicon) // 设置状态栏中的小图片,尺寸一般建议在24×24,这个图片同样也是在下拉状态栏中所显示,如果在那里需要更换更大的图片,可以使用setLargeIcon(Bitmap
                // icon)
                .setLargeIcon(bitmap)
                .setTicker(ticker)// 设置在status
                // bar上显示的提示文字
                .setContentTitle(title)// 设置在下拉status
                // bar后Activity,本例子中的NotififyMessage的TextView中显示的标题
                .setContentText(content)// TextView中显示的详细内容
                .setContentIntent(pendingIntent2) // 关联PendingIntent
                //.setNumber(1) // 在TextView的右方显示的数字,可放大图片看,在最右侧。这个number同时也起到一个序列号的左右,如果多个触发多个通知(同一ID),可以指定显示哪一个。
                .getNotification(); // 需要注意build()是在API level
        // 16及之后增加的,在API11中可以使用getNotificatin()来代替
        notify2.flags |= Notification.FLAG_AUTO_CANCEL;
        /*String ss = SharedPreferencesUtil.getStringData(context,ConstantUtils.ALLOW_NOTIFICATION,"true");
        LogUtils.i("notification--------" + ss);
        if(SharedPreferencesUtil.getStringData(context,ConstantUtils.ALLOW_NOTIFICATION,"true").equals("true")) {
            LogUtils.i("notification--------info--open" + ss);
            if((SharedPreferencesUtil.getStringData(context,ConstantUtils.ALLOW_VIBRATE,"true").equals("true"))
                    && (SharedPreferencesUtil.getStringData(context,ConstantUtils.ALLOW_SOUND,"true").equals("true"))){
                notify2.defaults = Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND;
                LogUtils.i("notification--------all--open" + ss);
            }else if(SharedPreferencesUtil.getStringData(context,ConstantUtils.ALLOW_SOUND,"true").equals("true")) {
                notify2.defaults = Notification.DEFAULT_SOUND;
                LogUtils.i("notification--------sound--open" + ss);
            }else if(SharedPreferencesUtil.getStringData(context,ConstantUtils.ALLOW_VIBRATE,"true").equals("true")) {
                notify2.defaults = Notification.DEFAULT_VIBRATE;
                LogUtils.i("notification--------shake--open" + ss);
            }
        }*/
        notify2.defaults = Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND;
        manager.notify(id, notify2);
    }
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:56,代码来源:NotificationUtils.java

示例14: previewSettings

private void previewSettings() {
    Notification.Builder builder = new Notification.Builder(this)
        .setContentTitle(getString(R.string.lc_preview_notif_title))
        .setContentText(String.format(Locale.getDefault(),
                getString(R.string.lc_preview_notif_text), getTitle()))
        .setSmallIcon(R.drawable.ic_notif_gravitybox)
        .setLargeIcon(Icon.createWithResource(this, R.drawable.ic_launcher));
    final Notification n = builder.build();
    if (mPrefsFragment.getLedMode() == LedMode.OFF) {
        n.defaults &= ~Notification.DEFAULT_LIGHTS;
        n.flags &= ~Notification.FLAG_SHOW_LIGHTS;
    } else if (mPrefsFragment.getLedMode() == LedMode.OVERRIDE) {
        n.defaults &= ~Notification.DEFAULT_LIGHTS;
        n.flags |= Notification.FLAG_SHOW_LIGHTS;
        n.ledARGB = mPrefsFragment.getColor();
        n.ledOnMS = mPrefsFragment.getLedOnMs();
        n.ledOffMS =  mPrefsFragment.getLedOffMs();
    }
    if (mPrefsFragment.getSoundOverride() && mPrefsFragment.getSoundUri() != null) {
        n.defaults &= ~Notification.DEFAULT_SOUND;
        n.sound = mPrefsFragment.getSoundUri();
    }
    if (mPrefsFragment.getInsistent()) {
        n.flags |= Notification.FLAG_INSISTENT;
    }
    if (mPrefsFragment.getVibrateOverride()) {
        try {
            long[] pattern = LedSettings.parseVibratePatternString(
                    mPrefsFragment.getVibratePatternAsString());
            n.defaults &= ~Notification.DEFAULT_VIBRATE;
            n.vibrate = pattern;
        } catch (Exception e) {
            Toast.makeText(this, getString(R.string.lc_vibrate_pattern_invalid),
                    Toast.LENGTH_SHORT).show();
        }
    }
    if (mPrefsFragment.getVisibility() != Visibility.DEFAULT) {
        n.visibility = mPrefsFragment.getVisibility().getValue();
    }
    if (mPrefsFragment.getVisibilityLs() != VisibilityLs.DEFAULT) {
        n.extras.putString(ModLedControl.NOTIF_EXTRA_VISIBILITY_LS,
                mPrefsFragment.getVisibilityLs().toString());
    }
    n.extras.putBoolean("gbIgnoreNotification", true);
    Intent intent = new Intent(ModHwKeys.ACTION_SLEEP);
    sendBroadcast(intent);
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).notify(++NOTIF_ID,  n);
        }
    }, 1000);
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:53,代码来源:LedSettingsActivity.java

示例15: build

public void build(){
      cBuilder = new NotificationCompat.Builder(NotifyUtil.getInstance().getContext());
      cBuilder.setContentIntent(contentIntent);// 该通知要启动的Intent

      if(smallIcon >0){
          cBuilder.setSmallIcon(smallIcon);// 设置顶部状态栏的小图标
      }
      if(bigIcon >0){
          cBuilder.setLargeIcon(BitmapFactory.decodeResource(NotifyUtil.getInstance().getContext().getResources(), bigIcon));
      }

      cBuilder.setTicker(ticker);// 在顶部状态栏中的提示信息

      cBuilder.setContentTitle(contentTitle);// 设置通知中心的标题
      if(!TextUtils.isEmpty(contentText)){
          cBuilder.setContentText(contentText);// 设置通知中心中的内容
      }

      cBuilder.setWhen(System.currentTimeMillis());
      //cBuilder.setStyle()

/*
       * 将AutoCancel设为true后,当你点击通知栏的notification后,它会自动被取消消失,
 * 不设置的话点击消息后也不清除,但可以滑动删除
 */
      cBuilder.setAutoCancel(true);

      // 将Ongoing设为true 那么notification将不能滑动删除
      // notifyBuilder.setOngoing(true);
      /*
       * 从Android4.1开始,可以通过以下方法,设置notification的优先级,
 * 优先级越高的,通知排的越靠前,优先级低的,不会在手机最顶部的状态栏显示图标
 */
      cBuilder.setPriority(priority);

      //int defaults = 0;

      if (sound) {
          defaults |= Notification.DEFAULT_SOUND;
      }
      if (vibrate) {
          defaults |= Notification.DEFAULT_VIBRATE;
      }
      if (lights) {
          defaults |= Notification.DEFAULT_LIGHTS;
      }
      cBuilder.setDefaults(defaults);


      //按钮
      if(btnActionBeens!=null && btnActionBeens.size()>0){
          for(BtnActionBean bean: btnActionBeens){
              cBuilder.addAction(bean.icon,bean.text,bean.pendingIntent);
          }
      }

      //headup
      if(headup){
          cBuilder.setPriority(NotificationCompat.PRIORITY_MAX);
          cBuilder.setDefaults(NotificationCompat.DEFAULT_ALL);
      }else {
          cBuilder.setPriority(NotificationCompat.PRIORITY_DEFAULT);
          cBuilder.setDefaults(NotificationCompat.DEFAULT_LIGHTS);
      }
      if(TextUtils.isEmpty(ticker)){
          cBuilder.setTicker("你有新的消息");
      }
      cBuilder.setOngoing(onGoing);
      cBuilder.setFullScreenIntent(fullscreenIntent,true);
      cBuilder.setVisibility(lockScreenVisiablity);

  }
 
开发者ID:Wilshion,项目名称:HeadlineNews,代码行数:72,代码来源:BaseBuilder.java


注:本文中的android.app.Notification.DEFAULT_SOUND属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。