android-service

Scheduled Alarm Manager not working Android

岁酱吖の 提交于 2019-12-03 15:39:29
I am trying to start an alarm service that repeats every day at a particular time. I have gone through a lot of threads on stack overflow regarding this but no luck. I followed a few tutorials: http://karanbalkar.com/2013/07/tutorial-41-using-alarmmanager-and-broadcastreceiver-in-android/ and http://javatechig.com/android/repeat-alarm-example-in-android My service is never started and I do not understand why. Below is my code: My Manifest file: <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses

What is the difference between service, intentService in android? [duplicate]

筅森魡賤 提交于 2019-12-03 14:48:50
问题 This question already has answers here : Service vs IntentService (11 answers) Closed last year . What is the difference between Service and an IntentService in Android? What is the difference between AsyncTask and an IntentService in Android? 回答1: 1. Difference between Service and IntentService Service : It is the base class for the Android services, that you can extend for creating any service. Since the service run inside the UI thread, it requires that you create a working thread for

Robospice - keep spice service continue running when changing activity

荒凉一梦 提交于 2019-12-03 14:21:37
I used RoboSpice library to do asynchronous tasks. From their examples, the spice service is declared in BaseActivity, it starts in activity's onStart method, and stops in activity's onStop. Everything is fine, but when I want download file from internet, and then I change to another activity, this download task is cancelled, because the spice service is stopped. It looks like: public abstract class BaseActivity{ /** The request manager. */ private SpiceManager requestManager = new SpiceManager(RequestService.class); @Override protected void onStart() { requestManager.start(this); super

Custom Account Type with Android AccountManager

落花浮王杯 提交于 2019-12-03 14:08:28
问题 I have an account type "mypackage.account" and a content authority "mypackage". I have a Service that provides an implementation of AbstractAccountAuthenticator , the addAccount method is implemented like this: /** * The user has requested to add a new account to the system. We return an intent that will launch our login * screen if the user has not logged in yet, otherwise our activity will just pass the user's credentials on to * the account manager. */ @Override public Bundle addAccount

List of Android task killers

北战南征 提交于 2019-12-03 14:04:50
问题 I am trying to do a list of Android task killers that are installed by default on the operating system. The problem is that Android is modified by the phone's manufacturer and it is hard to keep up with what everyone is doing. So far I have found this: Smart manager - On Samsung phones. Could not call alarm manager but you can avoid this if your package name contains "alarm" or "alert" Doze - On Android 6. should not interrupt the app but it may delay alarm manager or network processes

Show a notification only if Activity is not showing

99封情书 提交于 2019-12-03 12:32:41
问题 I have a background task I would like to handle. The thing is that when the task completes, I would like to call a new Activity to show the result to the user, only if my main Activity is showing, otherwise I would like to send just a notification so the user can see that the action completed, and be able to open it whenever he likes. I was thinking of using a service to handle the start and termination of the background task and broadcast a message when it finishes, but in this case I have

Implementing a thread pool inside a Service

空扰寡人 提交于 2019-12-03 11:26:59
I'm currently working on implementing a Service that when requested will perform some work on several parallel threads. My implementation is based on the ThreadPoolExecutor class along with a LinkedBlockingQueue . As a ground rule, once all tasks are finished and the are no pending tasks in the queue, I would like to stop the service (though the service can later on be started again and follow the same logic). I have been able to reach the desired outcome using the code below, yet I'm not sure if this approach is correct. public class TestService extends Service { // Sets the initial

How do I implement a BroadcastReceiver in a Service Class in Android?

寵の児 提交于 2019-12-03 09:20:31
问题 I need to implement BroadcastReceiver in a Service class I have created: public class MyService extends Service in this class I have to implement a Simulation of Download by using Thread - Sleep when the user presses the button in the MyActivity Class which implements sendBroadcas(). I cannot extends the Service class to BroadcastReceiver as it is already extendes to Service. Can anyone help me to figure it out how to implement this mechanism? thanks 回答1: Have the BroadcastReceiver as a top

Retriving image from server to android app

∥☆過路亽.° 提交于 2019-12-03 09:00:21
package com.sample.downloadImage; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; import org.apache.http.util.ByteArrayBuffer; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; import android.widget.ImageView; public class downloadImage extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Bitmap

Firebase + Android - Notifications ChildAdded - How to get only New Childs?

只愿长相守 提交于 2019-12-03 08:40:02
问题 I'm trying to setup an Android Service in my app that listens for new Childs in a Firebase Ref, and throws a Notification when that happens. I'm having issues because addChildEventListener onChildAdded apparently is called one time for every existent record and only then actually listens for new childs.. In this answer @kato states that if addChildEventListener is called like ref.endAt().limit(1).addChildEventListener(...) it would get only the newly added records. It actually only gets one