public void checkConnectionStatusNotification(String notificationText, Context context) {    String ns = Context.NOTIFICATION_SERVICE;    NotificationManager mNotificationManager = (NotificationManager) context    .getSystemService(ns);    int icon = R.drawable.icon; // 通知图标    CharSequence tickerText = "S_Fbuner..通知"; // 状态栏显示的通知文本提示    long when = System.currentTimeMillis(); // 通知产生的时间,会在通知信息里显示    Notification notification = new Notification(icon, tickerText, when);    notification.flags = Notification.FLAG_ONGOING_EVENT; // 将此通知放到通知栏的"Ongoing"即"正在运行"组中    notification.flags |= Notification.FLAG_AUTO_CANCEL; //在通知栏上点击此通知后自动清除此通知    notification.defaults |= Notification.DEFAULT_SOUND;// 通知的提示音    notification.defaults |= Notification.DEFAULT_VIBRATE;    RemoteViews contentView = new RemoteViews(context.getPackageName(),    R.layout.view);    Log.d("sunfb", "当前通知的包名:" + context.getPackageName());    // 通知布局适配 自定义方式       contentView.setImageViewResource(R.id.image, R.drawable.icon);    notification.contentView = contentView;//    Intent notificationIntent = new Intent(context, LoginActivity.class);    Intent notificationIntent = new Intent();    PendingIntent contentIntent = PendingIntent.getBroadcast(context, 0,    notificationIntent, 0);    notification.setLatestEventInfo(context, "S_Fbuner", notificationText, contentIntent);    mNotificationManager.notify(0, notification);}

  布局view.xml

<?xml version="1.0" encoding="utf-8"?>        

  注意如果你想要震动起效果就的添加震动的权限

转载于:https://www.cnblogs.com/sunfb/archive/2013/06/07/3124371.html

更多相关文章

  1. Android_notification通知
  2. Android(安卓)UI界面之TableLayout
  3. 一个旋转layout布局文件
  4. Android(安卓)通知提示功能
  5. android内置歌曲
  6. 56 Android(安卓)Notification 通知
  7. Android通知频道,通知点
  8. kotlin如何使用FragmentPagerAdapter
  9. Android应用欢迎界面实现

随机推荐

  1. android 圆角背景和通过menu键功能弹出po
  2. android MD5加密(二)
  3. Android(安卓)Socket网络通信
  4. Android中调用设备的照相和摄像功能
  5. Android(安卓)Studio设置类代码模板
  6. android listView的为空时显示
  7. Android(安卓)SharedPreferences使用
  8. Android(安卓)System.gc()注意点
  9. 【转】如何获取Android系统时间是24小时
  10. Android(安卓)命令行签名打包,加固二次打