intentservice

When to acquire wakelock for an intent service?

烈酒焚心 提交于 2019-12-12 01:44:14
问题 I am trying to understand the use of partial wake locks in android. I have a wakeful intent service which starts another intent service. If I don't acquire a wakelock for the called intent service, the intents will be processed when the CPU wakes up? Is there any scenario where these intents are not processed at all? 回答1: If you call startService() [whether directly or by calling send() on a service PendingIntent], it starts up the OS's process of spinning up that service. The device going to

Running an IntentService in BroadcastReceiver using AlarmManager

◇◆丶佛笑我妖孽 提交于 2019-12-12 01:38:47
问题 I want to call a Service in my Receiver class which extends BroadcastReceiver but the service didn't start and I got this error: FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start receiver com.example.ahmed.service.AlarmReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Context.getPackageName()' on a null object reference In my MainActivity, I call the alarm manager: // Calendar settings for AlarmReceiver Calendar cur

Send a cursor to an activity from a service

时光毁灭记忆、已成空白 提交于 2019-12-12 00:59:33
问题 I'm trying to send database cursor from a service(An IntentService) to my Activity(Which implements a Receiver to catch any response from the service). Once i get the data from query cursor = db.query(DBHelper.DB_BOOKS_TABLE, columns, where, whereArgs, groupBy, having, orderBy); i would like to send back the cursor from the service to his caller thru the receiver. but the bundle structure just let me send tical data(Strings, ints, thinks like that). i know the bundle also let send parcelable

Making http call using ion with in intent Service gives error on data network

♀尐吖头ヾ 提交于 2019-12-12 00:22:03
问题 I am using intentService for making http calls with Ion. On Wifi it works well but when I switch to data network things start breaking. Ion.with(Application.getApplicationContext()) .load(url) .as(new TypeToken<Object>() {}) .withResponse() .setCallback(new FutureCallback<Response<Object>>() { @Override public void onCompleted(Exception e, Response<Object> response) { if(e == null) { Bundle bundle = new Bundle(); bundle.putSerializable("result", (Serializable) response.getResult()); rec.send

Android Sending String from another app

扶醉桌前 提交于 2019-12-11 20:25:38
问题 I am working on two app, ApplicationA and ApplicationB, ApplicationA send String to ApplicationB,and i am display the receiving string on ApplicationB Activity.now everthing is working fine,when i Click on a Button from ApplicationA and want to send a string to ApplicationB,there is popup appear and i am select the ApplicationB from this popup,i want when i click on Button from ApplicationA the popup does not appear and directly my ApplicationB open and display the recieving string,also i

Background service in Android

给你一囗甜甜゛ 提交于 2019-12-11 19:27:22
问题 I'm working on an app where it has it's own DB and will be syncing with the backend via GCM, I'm thinking of using background service but I'm not sure if this is the right way to think about it, so, I would really appreciate if you can tell me the below is correct or not, if not can you please state what I need to do in steps or how should think about it? no code is required. When the app has no running/active activity, assume that GCM has a payload and no need to contact the backend, 1.

Android - how to run a task via “handler” periodically within a service-intent (worker-thread)

十年热恋 提交于 2019-12-11 18:17:05
问题 My question is Android related: How do I run a task every 20 seconds within an intentservice ? Problem is, I have to init some classes which will be used in the Handler "run" process. It works one time - but then the service stops & the application crashes when the handler-loop starts again after 20 seconds (probably because of the classes that got eliminated when the service stopped?). So maybe the solution is to get the service to stay running as long as the Handler runs or to throw away

I can not run service in android background

泄露秘密 提交于 2019-12-11 18:00:54
问题 I am running service in android background, and I have some problem. Over Android Oreo version, I tried to run endless service using AlarmService and StartForegroundService() in android. but I have got no result. My testing device is Xiaomi, YunOS, Huawei and android version is 9.0, 4.4 and YunOS 5.1 At first, when mainactivity run and next close, in onResume() and onPause() function, I started service with startforegroundservice() and startservice() function using Receiver. There are some

Listener registered within an IntentService receives notification only once

杀马特。学长 韩版系。学妹 提交于 2019-12-11 16:16:45
问题 I am writing a simple app to keep track of the periods when my phone has poor signal strength. I do this using an IntentService , which listens for PhoneStateListener.LISTEN_SIGNAL_STRENGTHS as follows: public class PoorSignalIntentService extends IntentService { private TelephonyManager mTelephonyManager; private PhoneStateListener mPhoneStateListener; public PoorSignalIntentService() { super("PoorSignalIntentService"); } @Override protected void onHandleIntent(Intent intent) {

Comunication between Service, Web and Activity, back and forth, in Android

情到浓时终转凉″ 提交于 2019-12-11 11:26:38
问题 I read most of the questions and answers around SO and I must say I still have no idea on which way to go, in my case. There are several ways to go with but I can't really decide which one is best suited for my case. What I've got I have an Service that gets started from my app. It checks the current location of the user and calls a web service with the read location. This occurs every x meters. What I want to obtain Have an activity with a map and display the current location readings from