package com.notification.activity;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
public class NotificationActivity extends Activity {
/** Called when the activity is first created. */
private static final int id=1;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Notification notification = new Notification(R.drawable.ic_launcher,"开始下载",System.currentTimeMillis());// 获得一个Notification对象
Intent intent = new Intent(this, NotificationActivity.class);// 这个是设置点击那个下拉框时,由那个进入到那个Activity
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);//获得系统的NotificationManager
PendingIntent contentintent=PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(this, "正在下载", "下载完成", contentintent);//下拉框时,listview上面的文字
manager.notify(id,notification);//使用或者激活这个Notificaiton
}
}
分享到:
相关推荐
Android push notification(即androidpn) 服务端源代码 非bin文件,而是源代码!
各种Notification的使用技巧
Notification的实用Demo
A simple Stopwatch that can be completely controlled from the notification bar. Very lightweight and no permissions. Uses Singleton design between Activity and Service. Supports Android 4.0 - ...
Notification
android notification完全解析Demo
疯狂Android中有关Notification的简单例子
android toast and notification练习代码
Notification最新用法、实现Notification的通知栏常驻、Notification的各种样式big View、解决Notification点击无效
前端项目-HTML5Notification,Notification polyfill
代码实现本地通知,有注释说明。notification
Create a List-Driven SharePoint Site Notification System源代码
目录这里我们分步解题:第一步:判断API第二步:NotificationChannel第三步:Notification第二个参数代码对比:拓展 这几天做一个小软件在API28(Android 9.0)的模拟器上测试时,发现通知栏无效,经过一番查询,...
Android 通知(notification)简单实用Demo,包含点击功能简单例子,供大家下载学习
npm install --save react-native-push-notification react-native link NOTE: For Android, you will still have to manually update the AndroidManifest.xml (as below) in order to use Scheduled Notifications...
示例功能包含普通Notification、折叠式Notification和悬挂式Notification,并且实现了Notification的显示等级。
使用javascript 封装实现 Notification 消息通知框
特别是重要的和需要长时间显示的信息,用Notification就最合适不过了。当有消息通知时,状态栏会显示通知的图标和文字,通过下拉状态栏,就可以看到通知信息了,Android这一创新性的UI组件赢得了用户的一致好评,就...