android-service

android alarm manager stops after few hours

ⅰ亾dé卋堺 提交于 2019-12-10 07:22:45
问题 I have create an alarm manager that start a service every 5 second, the app is running well but after few hours the alarm manager stop running. Note that the application is not used by the user which mean that it is running on background without user interaction. Does any one knows how to start a service every some second without stopping ? AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, AlarmManagerBroadcastReceiver.class);

OnHandleIntent() not called in IntentService

百般思念 提交于 2019-12-10 06:36:17
问题 I know this question has been asked before, but I've been over all of the answers I could find and still haven't been able to solve the problem. The issue is that when by BroadcastReceiver starts the IntentService onHandleIntent() isn't called. Weirdly enough the constructor does run (as I can see by the Log output). This is my code: NoLiSeA.class (This class contains the BroadcastReceiver that starts my service) public void toProcess(StatusBarNotification sbn) { LocalBroadcastManager

android startActivity from intent in service [duplicate]

£可爱£侵袭症+ 提交于 2019-12-10 05:33:48
问题 This question already has answers here : android start activity from service (6 answers) Closed 5 years ago . i try to use intent in service but when i try this : Intent intent_facebook = new Intent (this,MainUploadToYoutube.class); intent_facebook.putExtra("vid", vid); startActivity(intent_facebook); got this error on logcat : Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want? so i tried this from here : android

Can't fix MediaController.show() exception

喜夏-厌秋 提交于 2019-12-10 02:21:50
问题 I have an audio file playing in a foreground Service using MediaPlayer. When a user taps the notification associated with the foreground Service, I launch an Activity using the Intent like so: Intent audioPlayIntent = new Intent(context, AudioPlayActivity.class); audioPlayIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); audioPlayIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, audioPlayIntent, 0); This Activity then binds to

How to set the Permission WRITE_SECURE_SETTINGS in android? [duplicate]

こ雲淡風輕ζ 提交于 2019-12-10 01:36:32
问题 This question already has answers here : How can I get the dreaded WRITE_SECURE_SETTINGS permission for my android app? (3 answers) Closed 6 years ago . I am trying to enable the Accessibility Service Settings above 4.0 but It is showing an Exception i.e., Caused by: java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS In Manifest I have Declared This permission like this. <uses-permission android:name="android.permission

How to keep an IntentService running even when app is closed?

最后都变了- 提交于 2019-12-10 01:14:27
问题 In my Android app I start an IntentService from within an Activity by calling startService(new Intent(this, MyService.class)); And it works like a charm. I can move between Activies, press the Home button to switch to other apps... and it's still working. But if I remove my app from the recents screen, my service is stopped. How can I avoid this? In other words, how can I keep my service running even if my app is closed from recent apps? My service code is as follows: public class MyService

Started activity from home key screen

陌路散爱 提交于 2019-12-09 18:49:39
问题 I have a background Service which starts an activity, Intent i = new Intent(this, MyActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); After destroying this Activity and restart it over the "long press home key menu", this Activity starts again. But I want to start the main activity instead. How could I realise this? 回答1: Could you explain in more detail? If I understand your problem try setting the FLAG_ACTIVITY_NO_HISTORY. Alternatively a manual solution would be

Method onHandleIntent() does not get called

懵懂的女人 提交于 2019-12-09 17:48:16
问题 After many hours of researching I am finally consulting official help. Why does not onHandleIntent() get called? Is there something wrong here? In main activity onCreate() : mService = new Intent(context, xyz.class); startService(mService); That iss it. The onStartCommand() gets called, but not onHandleIntent() package com.autoalbumwallaperplus; import android.app.IntentService; import android.content.Intent; import android.widget.Toast; public class xyz extends IntentService { public xyz() {

Using Service as singleton in Android

丶灬走出姿态 提交于 2019-12-09 15:55:27
问题 Is it a bad practice to create a Service that works as a singleton? I mean a Service that is never stopped and that contains some private data that some other engines and Activities would use, so the Service could have something like: public class CustomService extends Service { private List<Profile> mProfiles; private static CustomService instance; public static CustomService getInstance() { if(instance == null) { instance = new CustomService(); } return instance; } public List<Profile>

Syncing a REST service with an android app

痞子三分冷 提交于 2019-12-09 15:45:07
问题 There's a REST service that I use to populate info in my database, that is later used by my app. I've read several threads on the matter, and now have to decide how I want the sync between the REST service and my DB to work. Think of an app that gets info from google finance APIs about stocks and stores it in a DB, displays the information when the app is launched, and sends notifications when specific events happen in the stock price. I already implemented the simple option of AsyncTask that