zoukankan      html  css  js  c++  java
  • 冲刺八

    冲刺八

    handler 

    创建handler

    private final Handler handler=new Handler(){
    public void handleMessage(Message msg) {
    super.handleMessage(msg);
    switch (msg.what) {
    case msg:
    showDialog(REGISTERATION_ACCOUNT_FAILURE);
    break;
    }
    };
    };

    在调用处调用 发送消息

    Message msg= Message.obtain();
    msg.what = msg;
    handler.sendMessage(msg);

    Notification

    protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            mContext = MainActivity.this;
            //创建大图标的Bitmap
            LargeBitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.iv_lc_icon);
            mNManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            bindView();
    
        }
    
    
        private void bindView() {
            btn_show_normal = (Button) findViewById(R.id.btn_show_normal);
            btn_close_normal = (Button) findViewById(R.id.btn_close_normal);
            btn_show_normal.setOnClickListener(this);
            btn_close_normal.setOnClickListener(this);
        }
    
    
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.btn_show_normal:
                    //定义一个PendingIntent点击Notification后启动一个Activity
                    Intent it = new Intent(mContext, OtherActivity.class);
                    PendingIntent pit = PendingIntent.getActivity(mContext, 0, it, 0);
    
                    //设置图片,通知标题,发送时间,提示方式等属性
                    Notification.Builder mBuilder = new Notification.Builder(this);
                    mBuilder.setContentTitle("叶良辰")                        //标题
                            .setContentText("我有一百种方法让你呆不下去~")      //内容
                            .setSubText("——记住我叫叶良辰")                    //内容下面的一小段文字
                            .setTicker("收到叶良辰发送过来的信息~")             //收到信息后状态栏显示的文字信息
                            .setWhen(System.currentTimeMillis())           //设置通知时间
                            .setSmallIcon(R.mipmap.ic_lol_icon)            //设置小图标
                            .setLargeIcon(LargeBitmap)                     //设置大图标
                            .setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE)    //设置默认的三色灯与振动器
                            .setSound(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.biaobiao))  //设置自定义的提示音
                            .setAutoCancel(true)                           //设置点击后取消Notification
                            .setContentIntent(pit);                        //设置PendingIntent
                    notify1 = mBuilder.build();
                    mNManager.notify(NOTIFYID_1, notify1);
                    break;
    
                case R.id.btn_close_normal:
                    //除了可以根据ID来取消Notification外,还可以调用cancelAll();关闭该应用产生的所有通知
                    mNManager.cancel(NOTIFYID_1);                          //取消Notification
                    break;
    
            }
        }
    }
  • 相关阅读:
    URL中“#”
    2、Distributed Optimization
    转:增强学习(二)----- 马尔可夫决策过程MDP
    转:强化学习(Reinforcement Learning)
    强化学习学习资料
    转:A Painless Q-learning Tutorial (一个 Q-learning 算法的简明教程)
    1、通过搜索进行问题求解
    CMOS与BIOS
    转:Spring-session & redis 子域名共享session
    基于 token 的认证应用
  • 原文地址:https://www.cnblogs.com/shunmu/p/12793830.html
Copyright © 2011-2022 走看看