Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/217.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android JobIntentService未调用手工_Android_Intentservice_Android Jobscheduler - Fatal编程技术网

Android JobIntentService未调用手工

Android JobIntentService未调用手工,android,intentservice,android-jobscheduler,Android,Intentservice,Android Jobscheduler,我不熟悉服务,决定使用JobIntentService,因为我的应用程序必须支持API 21+,但当我在API 28+上启动服务时,它无法正常工作 我发现当我使用Contextcompat.startForegroundService() 我的代码: 我的活动 Intent-Intent=新的Intent(这个,MyService.class); intent.putExtra(“fileTitle”,popup.name); ContextCompat.startForegroundServi

我不熟悉服务,决定使用JobIntentService,因为我的应用程序必须支持API 21+,但当我在API 28+上启动服务时,它无法正常工作

我发现当我使用
Contextcompat.startForegroundService()

我的代码:

我的活动

Intent-Intent=新的Intent(这个,MyService.class);
intent.putExtra(“fileTitle”,popup.name);
ContextCompat.startForegroundService(此,意图);
我的服务

@Override
    public void onCreate() {
        super.onCreate();

        MyLog(this, "SERVICE ONCREATE", "SERVICE");
        createNotificationChannel();
        initNotification();
        startForeground(NOTIFICATION_ID, nBuilder.build());
    }

为了结束这一主题,以下是我如何使其工作的:

我的活动

Intent-Intent=新的Intent(这个,MyService.class);
intent.putExtra(“fileTitle”,popup.name);
ContextCompat.startForegroundService(此,意图);
我的服务

@Override
    public void onCreate() {
        super.onCreate();

        MyLog(this, "SERVICE ONCREATE", "SERVICE");
        createNotificationChannel();
        initNotification();
        startForeground(NOTIFICATION_ID, nBuilder.build());
    }
@覆盖
public void onCreate(){
super.onCreate();
//API 26+中通知通道的初始化&显示初始化通知
createNotificationChannel();
初始化通知();
}
@凌驾
受保护的无效onHandleIntent(@Nullable Intent){
if(intent!=null&&isPostorEqualOS(Build.VERSION\u CODES.O)){
startForeground(通知ID,nBuilder.build());
}
}