基本信息
源码名称:消息推送最新demo 服务器
源码大小:0.53M
文件格式:.zip
开发语言:Java
更新时间:2016-06-14
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
通知栏消息推送提示
通知栏消息推送提示
package com.example.notificationtest; import android.app.Activity; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; public class NotificationActivity extends Activity implements OnClickListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.notification); findViewById(R.id.notificationBtn).setOnClickListener(this); } @Override public void onClick(View arg0) { // TODO Auto-generated method stub addNotification(); } private void addNotification() { NotificationManager manager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(); notification.icon = R.drawable.icon; notification.tickerText = "我在这里"; notification.defaults = Notification.DEFAULT_SOUND; notification.audioStreamType = android.media.AudioManager.ADJUST_LOWER; Intent intent = new Intent(this, Notification2Activity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); notification.setLatestEventInfo(this, "短信通知", "亲爱的,晚上8点老地方见哦~", pendingIntent); manager.notify(R.drawable.icon, notification); } }