intentservice

Android repeating alarm not repeating correctly

老子叫甜甜 提交于 2019-12-11 10:25:11
问题 I have an alarm that I am wanting to repeat around every 5 minutes. For testing purposes, I have it set to repeat once every 5 seconds instead, as such: AlarmManager alarmManager = (AlarmManager)getActivity().getSystemService(getActivity().ALARM_SERVICE); Intent intent = new Intent(getActivity(), CoordinateAlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getService(getActivity(), 1, intent, 0); int repeatSeconds = 5; alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,

IntentService not getting Intents from manifest registration

社会主义新天地 提交于 2019-12-11 09:33:03
问题 This IntentService (NotificationService in the snippet) isn't getting started and doesn't receive those Intents. By registering a receiver for them in the Application class, I've verified that those Intents are being broadcast. I just want to get them when the app isn't started. <service android:name=".services.NotificationService"> <intent-filter> <action android:name="com.redactedtoprotecttheinnocent.ACTION_INCOMING_CALL"/> <action android:name="com.redactedtoprotecttheinnocent.ACTION_CALL

stop IntentService from Activity

泪湿孤枕 提交于 2019-12-11 07:26:55
问题 I need help with this situation: I have activity, what starts IntentService. Service do some job in while cycle and sleep for some time. Main cycle of service is endless, so I need to stop it from activity again. I must be able to end activity, start it again and stop IntentService from new "instance" of activity. public class MyService extends IntentService { public MyService() { super("MyService"); } public MyService(String name) { super(name); } @Override protected void onHandleIntent

Android JobScheduler JobService not working

旧时模样 提交于 2019-12-11 06:14:27
问题 Hi I have implemented Android JobScheduler API which was working fine till recently but since 2/3 days there seems to be a inconsistent behaviour in jobs which are scheduled. Here is the jobinfo builder config : jobInfo = new JobInfo.Builder(118, new ComponentName(this, LocationJob.class)) .setBackoffCriteria(30000, JobInfo.BACKOFF_POLICY_EXPONENTIAL) .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) .setExtras(persistableBundle).build(); jobScheduler.schedule(jobInfo); Basic working is when

Android sensors and thread

て烟熏妆下的殇ゞ 提交于 2019-12-11 03:24:04
问题 I want to create an application where my sensors get values in another thread while the main thread is still working. I tried with just another thread, but it didn't working. I tried with a service and a IntentService, but the sensors start after the main thread. My current code is this. MyService.java public class MyService extends IntentService implements SensorEventListener { public MyService() { super("MyService"); } Sensor mLight; SensorManager mSensorManager; float max; float currentLux

Thread Synchronization with IntentService

心不动则不痛 提交于 2019-12-11 02:38:29
问题 I'm trying to create an app that makes HTTP requests through an intentservice. I need the app to wait for the service to finish its run (aka, have the request be returned with some data) before it continues its operations, as its operations involve manipulation of the data I hope to receive from the HTTP requests. I've tried numerous means of doing so - Semaphore, CountDownLatch, but it seems that for all of them, I need some method of passing in the waiting/counting object into the

Background Service stop after power saver enable and disable

被刻印的时光 ゝ 提交于 2019-12-11 02:15:43
问题 I have an application in which I perform some task in background, So the task will perform if my background service is running Problem : When I enable and disable power saver, so it close everything and stop every background services which are running. After turning off power saver the service is not getting start till I open the application. So how I can restart my background service when power saver off for lower version than Android.M Facing issue in Android 6.0 and below. Myservice.java

How to send a message from an Intent Service to an activity [duplicate]

随声附和 提交于 2019-12-10 21:39:59
问题 This question already has an answer here : send intent from service to activity (1 answer) Closed 5 years ago . Basically, i have an activity that has a progress dialog, i'm sending a message to an Intent to load all the data from the internet without any hiccup in the application. However, i was able to send a message to the service but i wasn't able to resend the message to the activity. What to do? Here's how i send message to the service: final Handler handler = new Handler() { @Override

How to determine app is running from service

房东的猫 提交于 2019-12-10 17:06:40
问题 This is the scenario... App is opened User clicks on a button that starts a service. User presses home key and then long presses home key and clears application from task list. Service continues to run, although app has closed. How from the runnning service can I determine whether that app has been killed or not? Is this possible? 回答1: I think this what you are looking for: private boolean isAppRunning() { ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY

Android - Best practice for retrying IntentService

僤鯓⒐⒋嵵緔 提交于 2019-12-10 16:56:06
问题 My Android app sends a load of files to Amazon S3. Each file URI is passed in separate calls to IntentService which performs the upload. However, I'm wondering what is the best way to handle failures... Should I detect the failure with my IntentService 's onHandleIntent() method and retry within that same method, OR should I allow the failure to be handled outside of the method (and if so, how?)? I'm personally leaning towards the first suggestion as I would prefer any file to be successfully