android中的通知,想必都用过把,来信息的时候会在屏幕的最上面显示,好了废话不说了 先看下效果图把
以上点击按钮会发送一个通知 并且点击通知会进入拨号盘
接下来 看代码把
//普通通知
public void send(View view){
//发送通知
//通知管理服务
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(android.R.drawable.ic_media_play//图标
, " 我是通知",//信息内容
System.currentTimeMillis());//时间
//跳转到拨号盘
Intent intent = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:1234"));
//延时意图 其实是对intent的一中分装
PendingIntent contentIntent = PendingIntent.getActivity(this,100,intent,0);
//事件 设置事件监听
notification.setLatestEventInfo(this,"标题","内容",contentIntent);//PendingIntent
//解决通知不销毁的方法 设置通知自动消失
notification.flags = Notification.FLAG_AUTO_CANCEL;
//添加到管理类中去
nm.notify(100, notification);
}
注释都有 应该都得懂 好了不懂再联系 我把