弹出通知
来源:互联网 发布:中美大都会 知乎 编辑:程序博客网 时间:2024/05/17 08:12
设置回调Intent
case SNSParam.NEWS_TYPE_INFO_CHAT://个人聊天
Intent chatIntent = new Intent(context, FriendMainTab.class);
chatIntent.putExtra(FriendMainTab.EXTRA_INDEX,FriendMainTab.TAB_CONVER);
StringBuffer chatBuffer = new StringBuffer();
chatBuffer.append(msg.getFromUser()).append(":").append(contentString);
showNotification(msg, context, chatBuffer.toString(),chatIntent, MOOD_SELF);
break;
case SNSParam.NEWS_TYPE_CIRCLE_CHAT://圈子
Intent circlemsg = new Intent(context, CricleMessgeActivity.class);
circlemsg.putExtra(MeettingMsgActivity.userids, msg.getFromId());
circlemsg.putExtra(MeettingMsgActivity.userNames, msg.getCircleName());
circlemsg.putExtra(MeettingMsgActivity.ISACTION, false);
StringBuffer circleBuffer = new StringBuffer();
circleBuffer.append(msg.getCircleName()).append(":").append(contentString);
showNotification(msg, context, circleBuffer.toString(), circlemsg,MOOD_SELF);
break;
/**
* 弹出通知public class ActNotifyDemo extends Activity {
Button _btn1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
_btn1 = (Button)findViewById(R.id.button1);
_btn1.setOnClickListener(new OnClickListener(){
//触发通知
public void onClick(View arg0) {
//获得通知管理器
NotificationManager manager = (NotificationManager) getSystemService(
Context.NOTIFICATION_SERVICE);
//构建一个通知对象
Notification notification = new Notification(R.drawable.icon,
"通知", System.currentTimeMillis());
PendingIntent pendingIntent = PendingIntent.getActivity(
ActNotifyDemo.this,
,
new Intent(ActNotifyDemo.this,ActNotifyDemo.class),
);
notification.setLatestEventInfo(getApplicationContext(),
"通知标题",
"通知显示的内容",
pendingIntent);
notification.flags|=Notification.FLAG_AUTO_CANCEL; //自动终止
notification.defaults |= Notification.DEFAULT_SOUND; //默认声音
manager.notify(0, notification);//发起通知
}
});
}
}
- 弹出通知
- 桌面弹出通知
- PowerShell弹出WIN10通知
- Chrome插件:弹出桌面通知
- 通知-键盘通知和模仿QQ拖拽弹出键盘
- 通知图标的弹出菜单问题
- 网站右下角弹出通知效果的制作
- iOS键盘弹出通知后加入动画
- 键盘弹出和收起的通知
- iOS8系统下的无法弹出通知
- iOS键盘弹出通知后加入动画
- iOS键盘弹出通知后加入动画
- iOS8系统下的无法弹出通知
- Android 弹出通知Toast的使用
- 键盘的弹出与消失(通知)
- Heads up 让通知弹出来
- 让TaryIcon(通知栏图标)弹出一个气球提示
- Toast(弹出信息)和Notification(下拉菜单通知)
- Intent 启动常用的应用与服务
- 智联招聘刷新简历
- 设计模式详解之单例模式
- chrome 开发者工具说明
- 升级镁光M4 SSD固件
- 弹出通知
- 第二次C程序设计作业
- 成功在mini2440上移植ffmpeg
- Ubuntu系统下vsftpd的安装
- GetCurrentProcessID、OpenProcessToken、LookupPrivilegeValue
- DS18B20温度读取笔记1-复位函数
- HTML/CSS规范指南 From Google
- ubuntu安装sun-java5-jdk
- [Project] 基开放云平台