我有一个调用意图服务的活动("ApplicationActivity")("DownloadService")
intentService在后台下载来自互联网的文件,但我希望能够中止特定的下载.........
所以我要说我把5个文件放在队列中:文件1,2,3,4,5
意图服务开始下载数字1,然后是第二个等等...... 1)有没有办法说意图服务中止你在方法句柄事件中当前正在做什么(在这种情况下下载文件) 1)并开始下载下一个?
2)是否可以从队列中删除元素,例如在下载文件1时,从队列中删除文件4,以便在数字3之后直接进入5?
不久,我需要一种方法来与队列通信来执行这两个简单的操作,但我没有在互联网上找到任何有用的东西:(
TNX
我有一个需要在后台运行的应用程序,所以我正在使用WakeFullService.但是在Asus Zenfone中它不起作用,因为Auto start manager不允许该应用程序运行.我的期望是:
在我们的应用安装期间或应用开放时在自动启动管理器中设置"允许权限".
华硕自动启动管理器是否有任何API可以帮助我检查我的应用程序的权限状态,以便我可以通过正常文本警报通知用户打开权限.
performance android android-service android-background android-intentservice
我在android应用程序中实现了Geofence.我按照这个链接在app中实现了'Geofence'.我正在使用'Retrofit'库来调用'HTTP'请求.
应用具有以下权限:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Run Code Online (Sandbox Code Playgroud)
这是我的'IntentService'代码:
public class GeofenceService extends IntentService
{
private static final String TAG = GeofenceService.class.getName();
public static final int GEOFENCE_NOTIFICATION_ID = 0;
public GeofenceService() {
super(TAG);
}
@Override
protected void onHandleIntent(Intent intent) {
// Retrieve the Geofencing intent
GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
createLoggerFile();
// Handling errors
if ( geofencingEvent.hasError() ) {
String errorMsg = getErrorString(geofencingEvent.getErrorCode() ); …Run Code Online (Sandbox Code Playgroud) 我在Play商店有一个应用程序,它IntentService在应用程序启动时有一些工作,并且它导致Android 5.0上的本机崩溃.此服务仅扫描资产文件夹以进行应用程序更新.
具体来说,这次崩溃似乎发生在升级到Lollipop之后的三星S5上,但我不知道它是否与该设备严格相关,因为它是一个意大利应用程序,在这里仍然是唯一广泛分散(即我知道)获得棒棒糖的设备.但是,我在模拟器上尝试了它,有了Android 5的股票,它运行正常.
我正在附加堆栈跟踪,任何有关如何继续的帮助将不胜感激...有本机问题,我不知道在哪里放我的手.
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'samsung/kltexx/klte:5.0/LRX21T/G900FXXU1BNL9:user/release-keys'
Revision: '14'
ABI: 'arm'
pid: 24219, tid: 24259, name: IntentService[I >>> it.mydomain.myapp <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
r0 afcb8c00 r1 001000e6 r2 af201428 r3 00000000
r4 76eb1338 r5 700981c0 r6 af50e4c2 r7 afcb8c00
r8 af201070 r9 b4f7e300 sl b4efac64 fp fffffb18
ip 00100002 sp af200f60 lr b4cd52ab pc b4cd52ca …Run Code Online (Sandbox Code Playgroud) 我遇到的问题是Activity + Service,我有以下数量的活动和服务.
LoginActivity => OrderListActivity => AddOrderActivity => ConfirmOrderActivity
在某个间隔的持续时间内,来自另一个单独服务的服务呼叫.
public class CheckAutoSyncReceivingOrder extends Service {
Timer timer;
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
if(timer != null) {
timer.cancel();
Log.i(TAG, "RECEIVING OLD TIMER CANCELLED>>>");
}
timer = new …Run Code Online (Sandbox Code Playgroud) android android-service android-activity android-intentservice
我对intentService有点困惑.文档说如果你发送一个intentService多个任务(意图),那么它将在一个单独的线程上一个接一个地执行它们.我的问题是 - 是否可以同时拥有多个intentService线程?如何区分在同一个intentService(同一个线程)上创建三个不同意图的代码,或三个单独的intentServices,每个都有自己的线程和一个意图执行?
换句话说,当您执行命令startService(intent)时,您是将意图放在单个队列中还是每次都启动一个新队列?
Intent someIntent1 = new Intent(this, myIntentService.class);
Intent someIntent2 = new Intent(this, myIntentService.class);
Intent someIntent3 = new Intent(this, myIntentService.class);
startService(someIntent1);
startService(someIntent2);
startService(someIntent3);
Run Code Online (Sandbox Code Playgroud) multithreading android worker-thread android-service android-intentservice
我有一个使用android.support.v4.os.ResultReceiver传递数据的IntentService.在IntentService中,当我使用ResultReceiver.send方法发回结果时,Android Studio显示错误说明
ResultReceiver.send只能从同一个库组中调用(groupId = com.android.support)
我在调用ResultReceiver的构造函数时收到类似的消息.但即使出现此错误,代码也会运行.在我将支持库版本升级到25.1.1后,这开始出现.
我该怎么办才能解决这个问题?
我在警报管理器中使用IntentService每15秒触发一次.我必须不断向服务器发送大量数据并在后台接收大量数据.我必须遵循以下流程:
我正在通过查询从数据库中读取数据.
然后通过POJO架构在Json中转换它.
使用Retrofit Library将此JSON请求发送到服务器.
接收数据作为回应.
如果数据库中有任何更新,则通过某些查询将此数据插入我的数据库.
还有其他方法吗?因为我正面临着ANR.如果数据较少,则其工作正常.但随着数据量变大,UI停止运行,应用程序变得无法响应.
我想从互联网上下载IntentService.我通过一个URL,通过Intent对IntentService通过调用startService(intentserive);.
如果我要求startService各种意图,那么意图会排队下载吗?
我是Kotlin的新手,也是使用intentService的一点点堆栈.Manifest向我显示一个错误,我的服务不包含默认构造函数,但在服务内部它看起来没问题且没有错误.
这是我的intentService:
class MyService : IntentService {
constructor(name:String?) : super(name) {
}
override fun onCreate() {
super.onCreate()
}
override fun onHandleIntent(intent: Intent?) {
}
}
Run Code Online (Sandbox Code Playgroud)
我还尝试了另一种变体:
class MyService(name: String?) : IntentService(name) {
Run Code Online (Sandbox Code Playgroud)
但是当我尝试运行此服务时,我仍然会收到错误:
java.lang.Class<com.test.test.MyService> has no zero argument constructor
Run Code Online (Sandbox Code Playgroud)
任何想法如何修复Kotlin中的默认构造函数?
谢谢!