@Overridepublic void onCreate() {    super.onCreate();    Log.d("MyService", "onCreate executed");    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {        NotificationChannel channel = new NotificationChannel("fore_service", "前台服务", NotificationManager.IMPORTANCE_HIGH);        NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);        notificationManager.createNotificationChannel(channel);        Intent intentForeSerive = new Intent(this, MainActivity.class);        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intentForeSerive, 0);        Notification notification = new NotificationCompat.Builder(this, "fore_service")                .setContentTitle("This is content title")                .setContentText("This is content text")                .setWhen(System.currentTimeMillis())                .setSmallIcon(R.mipmap.ic_launcher)                .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher))                .setContentIntent(pendingIntent)                .build();        startForeground(1, notification);    }}

更多相关文章

  1. 浅析android通过jni控制service服务程序的简易流程
  2. Android(安卓)Service AIDL
  3. Android架构分析之使用自定义硬件抽象层(HAL)模块
  4. android 定位服务
  5. 【安卓笔记】android客户端与服务端交互的三种方式
  6. android手机客户端上传文件,java servlet服务器端接收并保存到服
  7. android 定位服务
  8. Android例子—直接通过Binder的onTransact完成跨进程通信
  9. Android(安卓)启动过程(2)

随机推荐

  1. android studio 更新 Gradle错误解决方法
  2. Fragment的使用
  3. Android(安卓)视频播放框架之TigerVideoP
  4. Mac android studio升级时提示 :Connecti
  5. Android(安卓)build过程中already define
  6. AndroidのBitmap之大图片优化
  7. Android(安卓)语音控制 第三方框架 讯飞-
  8. android 模拟器 hardWare 特征说明
  9. Android通过URL获取网络数据
  10. Android联网使用HttpClient 和HttpRespon