zoukankan      html  css  js  c++  java
  • 通知 Notification

    1.

    NotificationManager ma=(NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);

    2.

          NotificationCompat.Builder b=new NotificationCompat.Builder(context);

    3.

    b.build().defaults=Notification.DEFAULT_SOUND;
    b.setSmallIcon(R.drawable.ic_launcher);
    b.setContentTitle("东方华尔");
    b.setContentText(msg);
    b.setTicker(ticker);
    b.setAutoCancel(true);
    Intent in=new Intent(context, HelloActivity.class);
    in.setFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
    in.putExtra("vadioId", vadioId);
    PendingIntent pIn=PendingIntent.getActivity(context, 1, in, PendingIntent.FLAG_ONE_SHOT);
    b.setContentIntent(pIn);
    Notification notification = b.build();
    notification.defaults=Notification.DEFAULT_SOUND;

    4.

    ma.notify(0, notification);

    5.

    ma.cancel(0);

    6.

    RemoteViews contentView = new RemoteViews(this.getPackageName(), R.layout.notification_layout);
    contentView.setTextViewText(R.id.fileName, videoInfo.getTitle());

    b.setContent(contentView);

    7.更新进度条

    RemoteViews contentView = notification.contentView;
    contentView.setTextViewText(R.id.progressRate, progress + "%");
    contentView.setProgressBar(R.id.progress, 100, progress, false);
    // 通知更新
    ma.notify(0, notification);

  • 相关阅读:
    js里面的 InttoStr 和 StrtoInt
    预编译知识 (转载记录)
    C语言操作内存
    C语言操作文件
    C语言
    如何调试shell脚本
    设计模式-装饰者模式
    自己动手制作一个模版解析
    设计模式-单例模式
    http中关于缓存的那些header信息
  • 原文地址:https://www.cnblogs.com/xxwn/p/4630562.html
Copyright © 2011-2022 走看看