android-service

android alarm manager stops after few hours

大城市里の小女人 提交于 2019-12-05 14:22:05
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); intent.putExtra(ONE_TIME, Boolean.TRUE); PendingIntent pi = PendingIntent.getBroadcast(context, 0,

binding a service to multiple activities

吃可爱长大的小学妹 提交于 2019-12-05 11:39:04
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; } }; bindService(new Intent(this, shareInfos.class), connection, Context.BIND_AUTO_CREATE); } @Override protected

Programmatically ending an ongoing notification - Android

情到浓时终转凉″ 提交于 2019-12-05 11:34:54
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 "playing" notification appears when the user presses play, but when they pause, that ongoing "playing"

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

坚强是说给别人听的谎言 提交于 2019-12-05 10:57:02
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 regardless the activity is in foreground. Can somebody suggest how can I implement this type of requirement.

Stopping an Android Service from within a thread

混江龙づ霸主 提交于 2019-12-05 10:16:00
I have a Service which starts a thread during onCreate() . The thread is monitoring hardware (IOIO) and will end once it is disconnected so essesentially is an infinite loop. Stopping the service from an Activity works fine and the thread also stops (ended in onDestory() ). My problem is that if the thread dies (say because of an exception) is it possible to stop the service that spawned it. I've tried using stopSelf() from within the thread code but the service does not stop. Thank you ps my first post so please excuse any missing conventions I should have followed. I think what you want here

MediaBrowserServiceCompat vs mediaSessionCompat?

假如想象 提交于 2019-12-05 08:20:34
问题 I just developed a music app (local songs) When trying to build playback control on lock-screen and notification using mediaSessionCompat I found ianhanniballake's following link: https://medium.com/google-developers/mediabrowserservicecompat-and-the-modern-media-playback-app-7959a5196d90#.kfvx5jfyn Though the blog was nicely explained, I didn't understand the difference between mediaSessionCompat and MediaBrowserServiceCompat. Can someone explain why MediaBrowserServiceCompat is used? Is it

Service is not stop in android. how to fixed issues

£可爱£侵袭症+ 提交于 2019-12-05 08:12:48
问题 I start service from an android activity startservice(intent); stopservice(intent); When i call for stopping service but service it does not stop actually my service class contains LocationListener that get latitude and longitude and then store in sqlite and also sent such information into server. Another issue is LocationUpdate method is automatically call after second How to extend time e.g 30 second How to stop service to stop LocationListener and storing value in sqlite server.

What is a JobService in Android

余生长醉 提交于 2019-12-05 07:30:31
I am inspecting the latest samples in Android-L developer SDK. There is a sample class in android-L/ui/views/Clipping/ClippingBasic called TestJobService . It extends from JobService , which in turn extends from Service . I see that JobService is a class in android.jar, but I cannot find any information on it in the dev guides, nor in the Android sourcecode www.androidxref.com . Has anybody seen this class or know what it's purpose is? matiash It's a new type of service, that is invoked for tasks that are scheduled to be run depending on system conditions (e.g. idle, plugged in). Entry point

Android Service - startService is called multiple times and causes value mixup…

别等时光非礼了梦想. 提交于 2019-12-05 07:17:13
I have some conditional calls from my code which starts same service with different data values passed through bundle to that service. When I checked for only one condition met, service works fine for all conditions. But when 2 or more conditions match, these calls this same service but with different data values in bundle. Problem is when this scenario is met the values sent by first call are not getting replaced for second condition to start same service. So service is responding wrongly. It is like this if(some cond) { some values in serivce intent bundle.startService(serviceintent1); } if

Android : Reading NFC tag in service class

落花浮王杯 提交于 2019-12-05 07:16:34
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 "MainActivity.java" protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);