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

软件工具
0 1161


通知的安卓代码:

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无广告纯净版 3098
Android QQ音乐 v11.3.7 定制版解锁免费听歌无广告版 3684
Android 草图大师SKP v1.5 解锁会员版 9035
Android OmoFun追漫神器 v4.2.1 无广告绿色版 6074
AdobeGenP Adobe全家桶系列激活工具 v3.5.0/3.4.14.1 绿色版 6652
Android 七猫免费听书 v1.4 解锁高级版 5060
超良心的抢票神器——Bypass1.16 4796
Android 玲珑加速器 v6.10.9.40 解锁无限时间 3446
Android 大师兄影视 v3.3.8 去广告会员版 2576
热门帖子
蚂蚁视界 v6.7.0 高清影视追剧APP 全品类视频播放软件 66
豆丁视频 v3.3.0 高清影视播放 免费追剧APP 64