Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/227.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 oreo和更高版本中,当应用程序完全关闭时,如何在特定时间获得通知?_Android_Android Studio - Fatal编程技术网

在android oreo和更高版本中,当应用程序完全关闭时,如何在特定时间获得通知?

在android oreo和更高版本中,当应用程序完全关闭时,如何在特定时间获得通知?,android,android-studio,Android,Android Studio,我试图在android设备中的特定时间获得本地通知,它在android版本8下运行良好,但当应用程序从内存中被杀死时,我无法在android oreo中获得通知。我尝试使用广播接收器和服务,但没有工作?有什么帮助吗…请使用作业服务进行此操作 ​<service ​android:name=".TestJobService" ​android:label="Word service" ​android:permission=

我试图在android设备中的特定时间获得本地通知,它在android版本8下运行良好,但当应用程序从内存中被杀死时,我无法在android oreo中获得通知。我尝试使用广播接收器和服务,但没有工作?有什么帮助吗…

请使用作业服务进行此操作

 ​<service
           ​android:name=".TestJobService"
           ​android:label="Word service"
           ​android:permission="android.permission.BIND_JOB_SERVICE" >

</service
import android.app.job.JobParameters;
import android.app.job.JobService;
import android.content.Intent;

/**
 * JobService to be scheduled by the JobScheduler.
 * start another service
 */
public class TestJobService extends JobService {
    private static final String TAG = "SyncService";

    @Override
    public boolean onStartJob(JobParameters params) {
        Intent service = new Intent(getApplicationContext(), LocalWordService.class);
        getApplicationContext().startService(service);
        Util.scheduleJob(getApplicationContext()); // reschedule the job
        return true;
    }

    @Override
    public boolean onStopJob(JobParameters params) {
        return true;
    }

}
在Android清单中为BOOT_COMPLETED事件注册接收器

import android.app.job.JobParameters;
import android.app.job.JobService;
import android.content.Intent;

/**
 * JobService to be scheduled by the JobScheduler.
 * start another service
 */
public class TestJobService extends JobService {
    private static final String TAG = "SyncService";

    @Override
    public boolean onStartJob(JobParameters params) {
        Intent service = new Intent(getApplicationContext(), LocalWordService.class);
        getApplicationContext().startService(service);
        Util.scheduleJob(getApplicationContext()); // reschedule the job
        return true;
    }

    @Override
    public boolean onStopJob(JobParameters params) {
        return true;
    }

}

import android.app.job.JobParameters;
import android.app.job.JobService;
import android.content.Intent;

/**
 * JobService to be scheduled by the JobScheduler.
 * start another service
 */
public class TestJobService extends JobService {
    private static final String TAG = "SyncService";

    @Override
    public boolean onStartJob(JobParameters params) {
        Intent service = new Intent(getApplicationContext(), LocalWordService.class);
        getApplicationContext().startService(service);
        Util.scheduleJob(getApplicationContext()); // reschedule the job
        return true;
    }

    @Override
    public boolean onStopJob(JobParameters params) {
        return true;
    }

}

你能分享任何样本项目请???我真的需要这个