android-service

How to get arguments for starting a service after device has been started?

Deadly 提交于 2019-12-11 17:40:02
问题 I'm trying to start a service after the device has been started. The problem is that the service needs some arguments which it normally gets this way: public class ServiceClass extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { searchString = (String) intent.getExtras().get(GET_SEARCHSTRING_AFTER_START); [...] return START_STICKY; public static final String GET_SEARCHSTRING_AFTER_START = "SEARCHVALUE"; public class OnStartupStarter[...] } But when

Want to hide Notification but getting Context.startForegroundService() did not then call Service.startForeground()

青春壹個敷衍的年華 提交于 2019-12-11 17:15:23
问题 I want to hide notification from appearing when the service is running in the background. I am aware that as per Google Play rules we have to show notification but for my current app i dont want to display any notification. Here is the code, which works fine and shows notification. But how to make it not show any notification: try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { String NOTIFICATION_CHANNEL_ID = "com.app.."; String channelName = "App Background Service";

Cannot find getApplicationContext() in class extended from FirebaseMessagingService

家住魔仙堡 提交于 2019-12-11 16:56:00
问题 I want to send and receive remote notification through Firebase but my custom class could not find getApplicationContext() method. From my understanding, FirebaseMessagingService extends Service , which extends ContextWrapper` which extends Context. So I don't know getApplicationContext() is not working. Any help will be appreciated! import com.google.firebase.messaging.FirebaseMessagingService; import com.google.firebase.messaging.RemoteMessage; public class FirebaseMessageService extends

Android: Scheduling long background task when system is idle

ぃ、小莉子 提交于 2019-12-11 16:49:30
问题 I'm writing an Android application that records video and then runs post processing on recorded video. Since post processing may take a while (up to an hour) I'm scheduling a service - JobService using JobScheduler to run when the phone is connected to power and idle i.e. to run at night. The job service doing the long-running job on a new thread. In practice my scheduled service is working VERY slow. It seems that although it runs when system is idle, it gets very little CPU bandwidth. Also

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) {

Why some apps don't need auto-run permission to run services in background in Xiaomi devices?

ぃ、小莉子 提交于 2019-12-11 14:48:08
问题 I recently came to know that unless you specifically ask the user to add your app in the "apps that can auto-run in the background" section, you cant make services which can run in the background in Xiaomi devices and other similar devices. But I have see some apps like this one which are added in the device's "apps that can auto-run in the background" section automatically as soon they get downloaded without even asking for permission. How is that possible? 回答1: The manufacturer (or mobile

Android Notification: GCM or Service [closed]

邮差的信 提交于 2019-12-11 14:13:00
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . I would like to notify (create a notification) user whenever he receives an in-app request. I'm using a MySQL Database with PHP - regular stuff. Whenever the value of the user_id_req field changes from 0 to 1 , the app should create a notification. I was able to do it on App

Capture camera frames in background (Android)

二次信任 提交于 2019-12-11 13:34:47
问题 My problem is this: I want a background service, that will obtain frames from the camera in real-time, so that I can analyze them. I've seen a lot of similar topics here that supposedly address this issue, but none of them has really worked in my case. My first attempt was to create an Activity, which started a Service, and inside the service I created a surfaceView, from which I got a holder and implemented a callback to it in which I prepared the camera and everything. Then, on a

Broadcast receiver not working when app is cleared from RAM

允我心安 提交于 2019-12-11 13:32:52
问题 I am new to android. I am making an alarm clock. Its working perfectly until the user clears the app from the RAM. On searching, I found that broadcast receivers don't work if the app is cleared from the RAM. So, what exactly should I do? Will sending the broadcast from a service help? Also if you have a link to a good tutorial to Services in android, pls do share. Also let me know if there is some other way to solve my problem. 回答1: In Xiaomi devices, you just have to add your app to

Send an Android Notification before an Activity has been launched

怎甘沉沦 提交于 2019-12-11 13:07:43
问题 EDIT: The problem below disappeared with no changes in code. The notifications started appearing properly upon later reboots. This is at most an intermittent issue. I have an application that starts up a background service when the phone boots. After a certain event is detected, I would like to send a notification to the user, allowing the user to elect to start my MainActivity if the user taps on the notification. The problem is that Android seems to disallow sending notifications if no