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

软件工具
0 768


通知的安卓代码:

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 QQ音乐 v11.3.7 定制版解锁免费听歌无广告版 1502
Android 草图大师SKP v1.5 解锁会员版 6893
Android OmoFun追漫神器 v4.2.1 无广告绿色版 3999
AdobeGenP Adobe全家桶系列激活工具 v3.5.0/3.4.14.1 绿色版 4600
Android 七猫免费听书 v1.4 解锁高级版 2823
超良心的抢票神器——Bypass1.16 2171
Android 玲珑加速器 v6.10.9.40 解锁无限时间 1392
Android 大师兄影视 v3.3.8 去广告会员版 576
DAWN 融资3300万美金,下一个挖矿空投大项目类似grass 866
热门帖子
零撸模式,有快手就可以做,每天零碎时间搞个几百块不成问题 2466
首发零撸项目 不看广告 手机随时可做 单日收益三位数 2284
手机发评论就有收益,一单10元日入9000+,新手小白复制粘贴秒上手 1176
今日头条视频纯原创玩法,拒绝搬运,AI一键成片, 2分钟一条爆款视频,… 1102
Android 绘梦轩 v1.0.0 去广告纯净版 680
闲鱼引流,暴力撸金,日盈利1000+,长期稳定!(附免费无货源渠道) 441
视频号分成计划,三天暴力起号玩法 单日稳定1000+ 379
海外游戏自动搬砖,无脑操作,日入千元,长期稳定收益 361
一天收益1000+ 视频号,快手 双平台项目 门槛低 , 上手快 347