zoukankan      html  css  js  c++  java
  • 光播的一些属性设置

    public class LocalReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
    Toast.makeText(context, "我是本地广播接受者", 3).show();
    Log.i("name", intent.getStringExtra("name"));

    // 通过发送广播来通知,光播如果做耗时操作一般会开启服务
    NotificationManager manager = (NotificationManager) context
    .getSystemService(context.NOTIFICATION_SERVICE);

    Intent intent2 = new Intent(context, ShowActivity.class);
    PendingIntent pi = PendingIntent.getActivity(context, 0, intent2, 0);

    RemoteViews rviews = new RemoteViews(context.getPackageName(),
    R.layout.mynotification);
    rviews.setImageViewResource(R.id.iv, R.drawable.clothing_0108);
    rviews.setTextViewText(R.id.tv, "我自定义的啊");
    // 声音
    File mediaPathFile = new File(Environment.getExternalStorageDirectory()
    .getAbsolutePath() + "/tiankong.mp3");
    Uri soundUri = Uri.fromFile(mediaPathFile);
    Notification notification = new Notification.Builder(context)
    .setContent(rviews)
    // 设置自定义通知界面
    .setTicker("未读消息提示")
    .setContentText("我是消息内容")
    .setContentTitle("我是消息标题")
    .setSmallIcon(R.drawable.ic_launcher)
    .setLights(Color.RED, 1000, 1000)
    .setSound(soundUri)
    .setVibrate(
    new long[] { 0, 2000, 1000, 2000, 1000, 2000, 1000 })
    .setWhen(new Date().getTime()).setContentIntent(pi).build();

    notification.flags |= Notification.FLAG_SHOW_LIGHTS;
    // 点击后,自动取消
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    // 管理器发送
    manager.notify(1, notification);
    }

    }

  • 相关阅读:
    DAY-4 Linux基础及常用命令(1)
    DAY-3 计算机基础之网络
    DAY-2 计算机基础之操作系统
    DAY-1 计算机基础
    梅花作品欣赏
    简洁大气网址(国外)跟设计大学的案例很像
    animate css3 应用的借鉴,一个同事写的JS
    漂亮的素材
    几个不错的素材站
    正式开始我的技术生涯
  • 原文地址:https://www.cnblogs.com/wangfeng520/p/5082955.html
Copyright © 2011-2022 走看看