zoukankan      html  css  js  c++  java
  • Notification.Builder

    Notification.Builder

    package com.example.notificationtest;

    import android.app.Activity;
    import android.app.Notification;
    import android.app.Notification.Builder;
    import android.app.NotificationManager;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;

    public class MainActivity extends Activity {
    private final int NOTIFICATION_BASE_NUMBER=110;

    private Notification n = null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button bn = (Button)findViewById(R.id.bn);
    bn.setOnClickListener(new OnClickListener(){

    @Override
    public void onClick(View v) {

    NotificationManager manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
    Builder notification = new Notification.Builder(MainActivity.this);
    notification.setSmallIcon(R.drawable.ic_launcher)
    .setTicker("通知来了!!")
    .setAutoCancel(false)
    .setContentTitle("这是标题~")
    .setContentText("这是内容");
    n = notification.getNotification();
    manager.notify(1 , n);

    }});
    }


    }

     

  • 相关阅读:
    rgb随机颜色函数
    mapshaper转geojson
    postgis
    Draw
    ol 聚类ol.source.Cluster的使用
    ol ---- overlay autoPan的使用
    多层数据注入同一个图层源时,要批量删除某一种要素
    js遍历数组,并从数组中删除元素
    echarts加载geojson
    centos65编译安装lamp和lnmp
  • 原文地址:https://www.cnblogs.com/Rookietake/p/5421382.html
Copyright © 2011-2022 走看看