Android 服务运行时没有Internet连接(活动已停止)
我已经用谷歌找到了一个解决方案,但什么也没找到。 我有一个独立于活动运行的服务,但如果活动暂停/停止,该服务将无法连接到Internet。 我使用一个线程来告诉我连接的状态,当活动返回到前端时,一切正常 对于IntentService,它也有同样的问题 这是我的服务(缩小到重要部分): } 该服务是通过以下方式启动的:Android 服务运行时没有Internet连接(活动已停止),android,service,Android,Service,我已经用谷歌找到了一个解决方案,但什么也没找到。 我有一个独立于活动运行的服务,但如果活动暂停/停止,该服务将无法连接到Internet。 我使用一个线程来告诉我连接的状态,当活动返回到前端时,一切正常 对于IntentService,它也有同样的问题 这是我的服务(缩小到重要部分): } 该服务是通过以下方式启动的: sIntent = new Intent(this, LoadService.class); pIntent = PendingIntent.getService(this, 0
sIntent = new Intent(this, LoadService.class);
pIntent = PendingIntent.getService(this, 0, sIntent, 0);
pIntent.send();
sIntent = new Intent(this, LoadService.class);
pIntent = PendingIntent.getService(this, 0, sIntent, 0);
pIntent.send();