intentservice

REST API Client Library for Android

末鹿安然 提交于 2019-11-28 13:43:27
问题 We are building a location based messaging app which uses Parse.com as back-end (Parse.com is similar to Urban Airship/PubNub, etc) and we now want to switch to our own back-end for better control. For this, we have built a node.js based back-end with functionality exposed over REST API To consume this API, we want to build an Android library (similar to Parse.com's Android SDK) which abstracts all the HTTP Requests/Response or REST API calls and provides direct functions for various

Send location updates to IntentService

 ̄綄美尐妖づ 提交于 2019-11-28 09:16:32
How can location updates be sent directly to Intent Service? The following approach does not work. OnConnected function is called but then the intent is never received in the service: ... private PendingIntent getLocationPendingIntent(boolean shouldCreate) { Intent broadcast = new Intent(m_context,LocationUpdateService.class); int flags = shouldCreate ? 0 : PendingIntent.FLAG_NO_CREATE; return PendingIntent.getService(m_context, 0, broadcast, flags); } @Override public void onConnected(Bundle arg0) { PendingIntent locationPendingIntent = getLocationPendingIntent(true); LocationRequest

intentservice no empty constructor, but there is a constructor

好久不见. 提交于 2019-11-28 08:51:09
问题 I have an IntentService within an Activity, and when I try to call the service, it throws this error, which I find strange because if I have the empty constructor declared. Error: 06-17 15:48:34.603: E/AndroidRuntime(13363): FATAL EXCEPTION: main 06-17 15:48:34.603: E/AndroidRuntime(13363): java.lang.RuntimeException: Unable to instantiate service cl.prosys.rac.activity.HomeActivity$UploadService: java.lang.InstantiationException: can't instantiate class cl.prosys.rac.activity.HomeActivity

How to create toast from IntentService? It gets stuck on the screen

微笑、不失礼 提交于 2019-11-28 07:21:37
I'm trying to have my IntentService show a Toast message, but when sending it from the onHandleIntent message, the toast shows but gets stuck and the screen and never leaved. I'm guessing its because the onHandleIntent method does not happen on the main service thread, but how can I move it? Has anyone has this issue and solved it? in onCreate() initialize a Handler and then post to it from your thread. private class DisplayToast implements Runnable{ String mText; public DisplayToast(String text){ mText = text; } public void run(){ Toast.makeText(mContext, mText, Toast.LENGTH_SHORT).show(); }

Android InstantiationException : No empty constructor

扶醉桌前 提交于 2019-11-28 06:07:08
问题 I get an InstantiationException when I try to start an IntentService. I have looked at other threads here but the answers don't solve my problem. My service class does have a default constructor. Here's my service class. (It is defined in a file FindMeService.java and that's the only class in that file.) package com.findme.findme; import android.app.IntentService; import android.content.Intent; import android.os.Bundle; import android.support.v4.content.LocalBroadcastManager; public class

WakefulIntentService implementation clarifications

前提是你 提交于 2019-11-28 04:32:47
问题 Commonsware's WakefulIntentService works beautifully but there are some things I do not quite get. Below is the core of the service - a stripped down version of the source : class WIS extends IntentService { private static final String NAME = WIS.class.getName() + ".Lock"; private static volatile WakeLock lockStatic = null; synchronized private static PowerManager.WakeLock getLock(Context context) { if (lockStatic == null) { PowerManager mgr = (PowerManager) context .getSystemService(Context

How do I keep the Thread of an IntentService alive?

穿精又带淫゛_ 提交于 2019-11-28 04:15:19
问题 I'm writing a test application which keeps track of the users location. The idea is that i can start a service which then registers for location updates. For now I'm using an IntentService for that. The service code (which is not working...) looks like that: public class GpsGatheringService extends IntentService { // vars private static final String TAG = "GpsGatheringService"; private boolean stopThread; // constructors public GpsGatheringService() { super("GpsGatheringServiceThread");

IntentService + startForeground vs JobIntentService

偶尔善良 提交于 2019-11-27 22:37:41
问题 Since Android Oreo background execution limits, the docs recommend to refactor IntentService s to JobIntentService . https://developer.android.com/about/versions/oreo/background JobIntentService runs immediately as an IntentService below Oreo, but schedules a Job on Oreo+ https://developer.android.com/reference/android/support/v4/app/JobIntentService In what cases would it make sense to run a normal IntentService as a foreground Service with a persistent notification, and when is a

Asking an IntentService for information about its queue

♀尐吖头ヾ 提交于 2019-11-27 20:49:57
I have an IntentService that queues up web service calls that need to be made to my web server. So each Intent is a web service call to be made. I'd like to set something up where my application can ask this IntentService if it has any Intents containing a particular piece of data (IE: "Are you already waiting to ask the cloud for x data? Or do I need to tell you to do it?"). Are there any suggestions on how I might extend IntentService to do this? Can the Intent queue of an IntentService be traversed? Or would I need to take the IntentService code and alter it? The only other idea I have is

Android how to check if the intent service is still running or has stopped running

本秂侑毒 提交于 2019-11-27 17:15:45
I need to know if all intentservices in the queue are "consumed" or the other way is to find out if it is still doing something so that I don't continue until all services have stopped running. Any ideas? Try this may be useful for u private boolean isMyServiceRunning() { ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if ("com.example.MyService".equals(service.service.getClassName())) { return true; } } return false; } 来源: https://stackoverflow.com/questions/7440473/android-how