intentservice

Listener for media button (headset-hook) using service without Activity

笑着哭i 提交于 2019-12-14 02:39:59
问题 How can I make service listen for media button (headset-hook) in android device . I try to do that using this code but did not work. Can you help me. Service code: public class RLservice extends IntentService { private Handler handler; public RLservice() { super("my service"); // TODO Auto-generated constructor stub } @Override public int onStartCommand(Intent intent, int flags, int startId) { handler = new Handler(); return super.onStartCommand(intent, flags, startId); } @Override protected

Using IntentService instead of AsyncTask for Broadcast Receiver?

て烟熏妆下的殇ゞ 提交于 2019-12-13 07:08:58
问题 I am in the process of trying to get an email sent using BroadcastReceiver, the code is working correct using AsyncTask when using onClick but does not work when AlarmReceiver is being called. Would it be better to use IntentService for this method? If so, what is the best way to write this? Can anyone help with this problem? I am still new to java and want to help improve my knowledge. :) Any help would be appreciated! Thank you! AlarmReceiver.java import android.app.Activity; import android

BroadcastReceiver from AlarmManager not getting called

自闭症网瘾萝莉.ら 提交于 2019-12-13 04:44:53
问题 I have a class that extends IntentService . The stuff in this class is called when my app reboots (and also on app startup). It loads some settings and does some stuff in the background (it's a productivity tool/utility). This IntentService , when loading my, let's call it "stuff" , decides whether or not to add some alarms via AlarmManager . I have a BroadcastReceiver that receives some different parameters and does some method based on those parameters. Here is the code in which I am

send List of objects with service using Parcelable [duplicate]

戏子无情 提交于 2019-12-13 04:08:12
问题 This question already has answers here : How to pass a parcelable object that contains a list of objects? (9 answers) Closed 5 years ago . First of all i need to retrieve the list of objects from FileUtils class. There i have the readFromAssets(Contex contex) method which returns the list. So i'm creating object from FileUtils and i'm getting the list. After that i have tried to implement Parcelable so i can send the list( i dont know if my implementation is OK ). And at the end to send the

Android: IntentService used in onDestroy()

删除回忆录丶 提交于 2019-12-13 02:36:46
问题 I am trying to delete a especific registry in a database once the user quits the app. For that issue I call an IntentService whichs runs theorically when the application id destroyed. The problem is that, although this intent does not work as intended and the registry is not deleted. Here is the code if you may help. IntentService: public class FinIntentService extends IntentService{ String levelstring = "22"; int pid; static String pids; BroadcastReceiver batteryReceiver = null; String url =

Android communication between applications using ResultReceiver

拟墨画扇 提交于 2019-12-13 01:56:59
问题 I have two applications. First application is simple service application which do some work in background and finish. I decided to use IntentService . @Override protected void onHandleIntent(Intent intent) { if (intent == null) { return; } ResultReceiver callbacks = intent.getExtras().getParcelable(EXTRA_CALLBACKS); ... The second application must consume the IntentService from the first using Intent in my case. public class SendActivity extends AppCompatActivity { private ResultReceiver

Android service killed immediately after start, despite calling startForeground()

房东的猫 提交于 2019-12-12 19:13:19
问题 I'm having a problem with my IntentService. Every time I start my service, the onDestroy() method is called as soon as the service becomes idle. I set up my service to run in the foreground, and despite this the service is still being killed right away. I have only one other activity in my application, and it is not calling stopService(). Reading the developer docs gives me the impression that calling startForeground() will allow your service to persist, even when idle, except when there is

IntentService onHandleIntent() still running after onDestroy() fired

筅森魡賤 提交于 2019-12-12 09:48:01
问题 In my preference screen, I want to start a service to download files from the internet when one of the preference is being clicked. If the service is already running (downloading files), then the service should be stopped (cancel download). public class Setting extends PreferenceActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); downloadPref.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean

What happen when my Activity is destroyed when I'm using IntentService with ResultReceiver

回眸只為那壹抹淺笑 提交于 2019-12-12 08:29:27
问题 I have searched through the net to find this answer. But no result found. Sorry that I'm a very newbie in Java & Android programming. I would elaborate on my question more. Let say my Activity started an IntentService and it's running independently in the background. The service is "subscribed" to the callback of ResultReceiver to update the Activity UI. And during the service is executing the long running process, the Activity is destroyed. So what will happen if the service send a reply or

Install APK EXTRA_RETURN_RESULT from IntentService

风流意气都作罢 提交于 2019-12-12 05:27:38
问题 I'm trying to get the results from an APK update, to a Service. Actually I'm using an IntentService, that is running in the background. My install is done by the Service creating a PendingIntent for Notification and then it's received in a BroadcastReceiver which calls the following: apkUri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".share", toInstall); Intent installIntent = new Intent(Intent.ACTION_INSTALL_PACKAGE); installIntent.setData(apkUri); installIntent