短视频带货源码,使用消息通知,不显示可能的原因

软件工具
0 1106


通知的安卓代码:

public class MyService extends Service {
…
public void onCreate() {
super.onCreate();
Log.d(“Myservice”, "onCreate execute ");
Intent intent = new Intent(this,MainActivity.class);
PendingIntent pi = PendingIntent.getActivity(this,0,intent,0);
Notification notification =new NotificationCompat.Builder(this)
.setContentTitle(“This is content title”)
.setContentTitle(“This is content text”)
.setTicker(“You have import thing to do it”)
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.mipmap.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher))
.setContentIntent(pi)
.build();
startForeground(1,notification);
}
}


这是安卓的服务中的代码,在活动MainActivity内要启动MyService:

case R.id.button2:
Intent intent = new Intent(this, MyService.class);
startService(intent);
break;


或者直接按钮的点击事件中显示通知:

case R.id.show:
Intent intent1 = new Intent(this,MainActivity.class);
PendingIntent pi = PendingIntent.getActivity(this,0,intent1,0);
NotificationManager manager =(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification notification = null;
notification =new NotificationCompat.Builder(this)
.setContentTitle(“This is content title”)
.setContentTitle(“This is content text”)
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.mipmap.ic_launcher)
.setLargeIcon(BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher))
.setContentIntent(pi)
.build();
manager.notify(2,notification);
break;



精选帖子
Android 可可影视 v3.3.6无广告纯净版 2872
Android QQ音乐 v11.3.7 定制版解锁免费听歌无广告版 3423
Android 草图大师SKP v1.5 解锁会员版 8769
Android OmoFun追漫神器 v4.2.1 无广告绿色版 5826
AdobeGenP Adobe全家桶系列激活工具 v3.5.0/3.4.14.1 绿色版 6402
Android 七猫免费听书 v1.4 解锁高级版 4841
超良心的抢票神器——Bypass1.16 4546
Android 玲珑加速器 v6.10.9.40 解锁无限时间 3213
Android 大师兄影视 v3.3.8 去广告会员版 2331
热门帖子
闷声赚钱的轻量玩法,一部手机15分钟,实测收益1000+稳定不破功 61
豆包AI+即梦+剪映制作胖橘猫动画,零基础可学,几分钟生产一条视频,附提示词 61
随时随地,每天十几分钟,一部手机轻松日入500+,长期稳定 49
Seedance 2.0 AI电商实战课:不用实拍不出镜,批量生产爆款视频打爆GMV 46
剪映+豆包+即梦3.0免费做龟兔赛跑绘本视频,小白轻松学会儿童动画 44
小红书AI虚拟电商2.0,半精细化选品,配合AI日入五张 44
番茄小说全新技术全新玩法!无脑日收300+ 42
日入四位数!Ai全自动快手短视频带货,绿色长期稳定,一刀不剪纯搬运,每天操作半小时 42
AI代做动画疯了,一小时出一套,单子接不完,提供派单资源,月稳2W! 41