在orio(8.0)及更高版本中在后台连续运行服务,以在后台生成调用

时间:2019-07-31 05:18:04

标签: android android-jobscheduler

我有向我发送命令的外部硬件设备,接收到该命令后,我需要使用服务类在后台生成呼叫和短信。为此,我有2个服务,分别称为Service1和Service2,其中Service2用于短信和后台调用处理(而应用被终止),而Service1仅用于调用/启动Service2。每当我从外部设备收到命令Service1都会被调用.Service1调用/启动Service2这是后台服务。我从外部设备获取命令,但是当该应用在android 8.0和更高版本中被杀死时,我无法生成调用和短信以上。 我尝试使用Job Schedular来执行此操作,但是按我的要求它不起作用。

//Service1 - to call background service 
startService(new Intent(getApplicationContext(),BackgroundService.class));
//service2 - background service 
final Handler handler = new Handler();
handler.postDelayed(new Runnable(){
@Override
public void run(){
SOS sos = new SOS(getApplicationContext());
sos.sosMethod();// Call and SMS Class
}},1000);

0 个答案:

没有答案