android-service

AlarmManager never calling onReceive in AlarmReceiver/BroadcastReceiver

瘦欲@ 提交于 2019-12-07 08:14:11
问题 I still cannot get my AlarmReceiver class' onReceive method to fire. Does anything stick out as wrong with this implementation? All this is supposed to do is wait a certain period of time (preferably 6 days) and then pop up a notification. (Can you believe there isn't a built in system for this? crontab anyone!?) MyActivity and BootReceiver both set up an alarm under the necessary conditions. AlarmService kicks out a notification. And AlarmReceiver is supposed to catch the alarm and kick off

Android Media Player using service

爷,独闯天下 提交于 2019-12-07 07:15:01
问题 I created a MediaPlayer class to play mp3 files. Everything was fine, then my player stopped playing while it was in background and I found out that my problem was I did not create it in a service, so I started to read about services to learn how to create one and use it for my player. My question is, what is the best way for me to communicate between the service and my application? Should I use the message or send intents or bind it? I should also create a UI in notification area, also to

Programmatically ending an ongoing notification - Android

大兔子大兔子 提交于 2019-12-07 06:43:14
问题 I am developing a GPS-based app and have just started adding in my UX features such as notifications and progress bars but I'm stuck on using an ongoing notification. As it is a GPS app, when user tracking is started, I set up an ongoing notification to show that they are being tracked but how do I stop this notification when they tap "stop tracking" in my app? Do I have to tell the NotifyManager something? I'm basically trying to get the functionality that music players have, as in the

Call service method from notification with BroadcastReceiver in Xamarin Android

妖精的绣舞 提交于 2019-12-07 06:08:25
I start a service and create new thread (downloading a large file). At the same time I display a notification with action (pause button). When I press this button "WSTRZYMAJ" I want call PauseDownload() method from my service. How can I do this? I have read about BroadcastReceiver, create this class but how to call method from service from BroadcastReceiver class? Screen from notification: Fragment of my service: class DownloadsService : Service { DownloadsBroadcastReceiver receiver; Notification.Builder notificationBuilder; DownloadsData downloadsData; int uniqueNumber = 1000; bool isStarted;

How to keep Listening for Push Notifications on Android in the background

北城余情 提交于 2019-12-07 06:04:15
问题 I am working on Push Notifications in Android. Now the issue is that I want to keep running my Push Notifications on the back ground as soon as the app start because I have no idea when the server will push the data to the devices. The main requirement is that our corporate app is having more than 10 activities and based on the notification received, I have to bring the related activity on the foreground so that user can preform action on that or do some silent action in the background

binding a service to multiple activities

Deadly 提交于 2019-12-07 04:48:33
问题 My service is correctly binded to my first activity but when I try to bind it to a second activity it does not work Here is the code of onresume and on pause of my first activity @Override protected void onResume() { super.onResume(); connection = new ServiceConnection() { @Override public void onServiceDisconnected(ComponentName name) { service = null; } @Override public void onServiceConnected(ComponentName name, IBinder service) { shareInfos.this.service = (IService) service; } };

How to programmatically check if a service is declared in AndroidManifest.xml?

回眸只為那壹抹淺笑 提交于 2019-12-07 03:25:13
问题 I'm writing a library that provides a Service that is used by other developers by including it in their project. As such, I don't have control over the AndroidManifest.xml. I explain what to do in the docs, but nevertheless a common problem is that people neglect to add the appropriate <service/> tag to their manifest, or add it in the wrong place. Right now, when my library calls startService while the service isn't declared in the manifest, the only thing that happens is that

Android : Reading NFC tag in service class

时光怂恿深爱的人放手 提交于 2019-12-07 03:05:38
问题 I am working on an application where i need to read the data stored in NFC tag, by data i mean is simple integer values as such 0,1,2,3 and so. The functions to read the data from NFC works fine when it's in Activity class but i need to run the application in the background so even when application is not running in foreground i can read the data from the NFC. So i wrote a service class and moved the function from the Activity to the service class. But it didn't work. This is the

Resume background activity on notification

半腔热情 提交于 2019-12-07 00:45:33
I've read some answers here, I think I have what I need in order to achieve my result, but I need some help. My app launches an notification on specific conditions, and I need my app to behave as follow: if there is an instance of my main activity running in background I need to make it to the foreground (I found this on the site: intent.setFlags(FLAG_ACTIVITY_REORDER_TO_FRONT); , so I think this point is solved; if there isn't any activity of the app running in background I need to start the app from the beginning (and this can be achieved starting the launcher activity of the app.); My

Can a third-party app implement CallScreeningService in android 7?

假如想象 提交于 2019-12-06 22:02:19
问题 Android API level 24 introduces a new Service called the CallScreeningService. The documentation says that the service can by implemented by the default dialer to screen incoming calls. I would like to implement this service in my own app, preferably without creating an entire dialer app, but a simple naive implementation seems to be ignored by the OS when an incoming call happens. AndroidManifest.xml snippet: <service android:name="com.example.callbouncer.CallService" android:permission=