弹出通知



设置回调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);//发起通知
            }
        });
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值