相关疑难解决方法(0)

android oreo的后台服务

如何在没有显示通知点的情况下在android Oreo中继续后台服务?我使用通知继续我的后台服务,但我不想显示运行服务的通知.

java android push-notification android-service android-8.0-oreo

12
推荐指数
2
解决办法
2万
查看次数

如何在奥利奥长期运行后台服务?

Android Oreo对运行后台服务施加了很多限制.现在服务在Oreo中的表现与以前一样.

但是,如果我必须在后台运行很长一段时间的服务,该怎么办呢?

我正在开发一个应用程序,当用户摇动手机时启动手电筒.为此,我必须将Sensor侦听器代码放在服务中.

如何防止android系统不杀死服务.

PS:我不想通过通知启动前台服务.

android android-8.0-oreo

5
推荐指数
2
解决办法
1万
查看次数

奥利奥:广播接收器不工作

每当用户拨打新电话时,我都试图在我的应用程序上获得通知触发器.我在我的活动中注册接收器并在onDestroy()方法中销毁它.以下是用于注册的代码片段

registerReceiver(inComingCall = new IncomingCall(),new IntentFilter("android.intent.action.PHONE_STATE"));
Run Code Online (Sandbox Code Playgroud)

我面临的问题是我没有在广播接收器的覆盖onReceive()方法中获得任何触发器.请告诉我是否有任何新的实施方式或我应该采取的单独方式来接收特别是奥利奥的广播.

提前致谢.

android broadcastreceiver android-broadcast android-8.1-oreo

4
推荐指数
1
解决办法
8235
查看次数

不允许启动服务Intent - Android Oreo

我目前正在使用在奥利奥崩溃的startWakefulService函数.我意识到要么必须切换到startForegroundService()并使用前台服务,要么切换到JobIntentService,但根据我的代码,我不知道该怎么做.(对不起,我是一个Android新手).任何正确方向的点都将非常感激.

public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {

    // Explicitly specify that GCMIntentService will handle the intent.
    ComponentName comp = new ComponentName(context.getPackageName(), GCMIntentService.class.getName());
    // Start the service, keeping the device awake while it is launching.
    startWakefulService(context, (intent.setComponent(comp)));

    setResultCode(Activity.RESULT_OK);
}
}
Run Code Online (Sandbox Code Playgroud)

这是我在Android 8.x上运行时遇到的当前错误

致命异常:java.lang.RuntimeException无法启动接收器com.heyjude.heyjudeapp.gcm.GcmBroadcastReceiver:java.lang.IllegalStateException:不允许启动服务Intent {act = com.google.android.c2dm.intent.RECEIVE flg = 0x1000010 pkg = com.app.app cmp = com.app.app/.gcm.GCMIntentService(has extras)}:app在后台uid UidRecord {f602fba u0a114 RCVR idle procs:1 seq(0,0,0)}

java android android-8.0-oreo

4
推荐指数
1
解决办法
1万
查看次数