android-service

Android get current song playing and song changed events, like Musixmatch

烈酒焚心 提交于 2020-01-12 09:52:16
问题 What i want to achieve is very similar to what Musixmatch is doing. I need to be informed when the music starts playing and when the song is changed. All this in the service because my app may be closed (even musicmatch does this). In the above case even if Musixmatch app is not running i get a notification when ever i change the song on spotify or any player. Can anyone pls tell me how to achieve this. I don't need the code help, just what to know how to achieve it. I'm really confused how

Robospice - keep spice service continue running when changing activity

♀尐吖头ヾ 提交于 2020-01-12 07:29:27
问题 I used RoboSpice library to do asynchronous tasks. From their examples, the spice service is declared in BaseActivity, it starts in activity's onStart method, and stops in activity's onStop. Everything is fine, but when I want download file from internet, and then I change to another activity, this download task is cancelled, because the spice service is stopped. It looks like: public abstract class BaseActivity{ /** The request manager. */ private SpiceManager requestManager = new

Run a service with Root privileges or adding permissions with root

天涯浪子 提交于 2020-01-12 03:23:21
问题 I am currently developing an app that reads out SMS/Emails while driving. Many users wished support for WhatsApp / KakaoTalk. However, as there is no "official" way to receive their messages, there would be only three options, all requiring root: The easier way of scanning their database in a given intervall. Easy to implement. However not battery efficient Also the messages are not read out immediately. An other way would be to run a service with root rights and register a receiver that

Android Services: START_STICKY does not work on Kitkat

↘锁芯ラ 提交于 2020-01-11 15:30:21
问题 I am using services in an application to listen for how many times the user presses his/her power button. The implementation was working fine on all devices. But when I tested the app on the Android Kitkat, I noticed something wrong. As soon as I swipe the application away from the recents apps, the application no longer listens for the power button. Here is the code that I am working with: public class Receiver extends Service { Notification notification; private static final int

Google IO Rest design pattern, finished ContentProvider and stuck on getting the data from the network

柔情痞子 提交于 2020-01-11 14:48:32
问题 After watching the very known video on this topic I decided to go with design pattern B. Using a contentprovider with servicehelper. Basically I have the following files: MyProvider MyDatabase Mycontract In the activity I can now get the contentresolver and query the provider. All is working great so far. Now I need to sync my contentprovider to fetch data from my REST API. Thus I need to implement a service helper service and Rest method. Studying the Google IO app has helped me a lot, I'm a

Alarm receive don't work

爱⌒轻易说出口 提交于 2020-01-11 13:15:10
问题 I'm making an alarm receiver, but the alarm is not triggered. This is my code : Start alarm in MainActivity : private void setupAlarm(){ Intent intent = new Intent(this, com.logdata.AlarmReceiver.class); PendingIntent pIntent = PendingIntent.getService(this, 0, intent, 0); AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); manager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,SystemClock.elapsedRealtime() + 1, 1000, pIntent); Log.e("setupAlarm", "Setup alarm

Starting Service in Android calls Applications onCreate

有些话、适合烂在心里 提交于 2020-01-11 09:13:46
问题 I am starting an android service using, startService(getApplicationContext(), MyService.class); I have correctly defined my service in AndroidManifest. Now, I am calling above code from Application create. Case 1: Calling above code from Application onCreate() I see that Application.onCreate() gets called two time. One is the desired App create and other happens when startService is called. Case 2: Calling above code from Activity in application Same behavior as case 1. Is this intended

Save data in activity's onDestroy method

此生再无相见时 提交于 2020-01-11 01:48:08
问题 I'm writing a tasklist and have Project object, which holds all the tasks (and metadata). I use action log, so when tasks changes i do not save it immediately to database, just keep it in memory to dump in database on activity finish. Activity's onDestroy method is best place for this: if no onRetainNonConfigurationInstance method was called I start service to save project (one's instance is stored in Application). Saving is expensive: In DB project have revision, so I save new data, change

Rapid IPC with Messengers or AIDL

我的未来我决定 提交于 2020-01-10 02:59:11
问题 I'm attempting to create a program in Android which communicates rapidly with a remote service (~40,000/sec), however all Android IPC seems to fall short of being able to accomplish this task. My first attempt involved a standard Messenger system which was unable to do more then ~2,000/second and equally bad was that it seemed punctuated with intermittent lag. MainActivity (Test with Messengers) public class MainActivity extends Activity implements ServiceConnection{ Messenger

Android location updates in a Service

╄→гoц情女王★ 提交于 2020-01-09 09:42:31
问题 I want to do something like this: When my application starts I want to start a Service which should check my location When the application goes to background I want to stop the service I have two major problems: How can I detect that my application goes to background? I haver several activities, and I tried that in my MainActivity overriding onPause, but the onPause is also called when I start an other activity. This problem is more important: How should my Service which checks for my