android-service

java.lang.RuntimeException: WakeLock under-locked C2DM_LIB

旧街凉风 提交于 2019-11-28 18:08:07
I have uploaded my application on google play but users have reported the following exception java.lang.RuntimeException: WakeLock under-locked C2DM_LIB . This exception occurs when I try to release the WakeLock . Can anyone tell what could be the problem. HitOdessit I have traced same exception in new GCM Library too. Actually old C2DM Android library have same error, same crash, and Google hasn't fixed it yet. As I can see by our statistics, about 0.1% of users experiencing this crash. My investigations shows that problem is in incorrect releasing of network WakeLock in GCM library, when

Set “allow” permission by default in “Asus auto start manager” from code

不想你离开。 提交于 2019-11-28 17:38:18
I have an application which needs to run in the background, so I'm using a WakeFullService for that. But in Asus Zenfone it's not working because Auto start manager does not allow the app to run. My expectation is: To set "allow permission" in auto start manager during our app install or at the time of app opening. Is there any API available from ASUS Auto Start Manager which can help me check the permission status of my app so that I can notify the user via normal text alert to turn on the permission. Someone did it for Huawei: "Protected Apps" setting on Huawei phones, and how to handle it

Android ResultReceiver across packages

流过昼夜 提交于 2019-11-28 17:14:32
问题 I have an activity in package A (SignerClient), and a service in package B (MyService) The activity's resultreceiver: private ResultReceiver resultreceiver = new ResultReceiver(null) { @Override protected void onReceiveResult(int resultCode, Bundle resultData) { ... } }; Starting the service: Intent intent = new Intent("com.example.STARTSERVICE"); intent.putExtra("resultreceiver", resultreceiver); startService(intent); Receiving end: ResultReceiver rr = (ResultReceiver) intent

Android: When to use Service vs Singleton?

六月ゝ 毕业季﹏ 提交于 2019-11-28 17:11:29
I'm quite new to Android development. When is it a good idea to create an Android Service instead of just using a simple Singleton class? Take, for example, the data layer downloading information feeds from the internet. Using a Service seems too much for some cases but sometimes I might need access to a Context so I'm a little unsure about how to design the app. If it is okay for your process to be killed (along with the singleton) immediately after the user leaves its activities, then use a singleton. If you need it to continue running for some duration after that, use a service. If you

In Oreo (8.0.0+) (API 26+), How to get a location services update when the app is in the background or kill

南楼画角 提交于 2019-11-28 16:35:10
In Android O (8.0.0+) (API 26+), How to get a location services update when the app is in the background or kill. In "Strava" Android App (Available on Play Store ), location services run properly when the app is in the background or kill. I need to build same functionality in my app. Whenever I start service using startService(new Intent(this, GpsServices.class)); Then the onDestroy method is called after 10 sec when an app is an idle mode (the app is in the background or kill). Below is my code. public class GpsServices extends Service implements LocationListener, Listener { @Override public

Permanently listen to Clipboard changes

喜夏-厌秋 提交于 2019-11-28 16:25:24
I'm building an application that will launch a service capable to listen to clipboard changes. What i really want is to record (and write it in storage) every single change in the clipboard permanently, so when i launch my app i can read the stored files written by that service. This means, there's no need for direct communication between my app and the service and there's no need to use wakelocks to keep the device up (since the clipboard hardly changes while the device is asleep). I'm using a handler to recurrently check the clipboard, I want to know how can I implement the clipboardListener

Minimal android foreground service killed on high-end phone

霸气de小男生 提交于 2019-11-28 16:19:18
问题 I'm trying to create an app that lets users log routes (locations/GPS). To ensure locations are logged even when the screen is off, I have created a foreground service for the location logging. I store the locations in a Room Database which is injected into my service using Dagger2 . However, this service is killed by Android which is, of course, not good. I could subscribe to low memory warnings but that doesn't solve the underlying problem of my service getting killed after ~30 minutes on a

Exported service does not require permission: what does it mean?

£可爱£侵袭症+ 提交于 2019-11-28 15:45:30
I created a service that is bound by other applications through AIDL, and I add it to the manifest as follows: <service android:name=".MyService"> <intent-filter> <action android:name="org.example.android.myservicedemo.IService" /> </intent-filter> </service> where IService is the AIDL interface. In this way, Eclipse show me the warning Exported service does not require permission . If I remove the intent-filter , the warning disappear, but obviously the applications are unable to bind to the service. What does this warning mean? Nam Vu I had the same issue when I updated SDK to version 20 . I

Using Google Play Services LocationClient in background service

不羁的心 提交于 2019-11-28 15:38:01
问题 My app is designed to track user's location periodically and send it to server, Recently I changed my code with Google play services Location API. I created the locationclient and connected to the service in onStartCommand public int onStartCommand(Intent intent, int flags, int startId) { setUpLocationClientIfNeeded(); if(!mLocationClient.isConnected() || !mLocationClient.isConnecting()) mLocationClient.connect(); return START_STICKY; } and in onConnected method, I send a location request,

Android - Unable to receive local broadcast in my activity from service

可紊 提交于 2019-11-28 14:32:40
I have my main activity that start a service (Location service) and I want that service to broadcast the new location each time a new location is found. Thanks to the log I know the service is working and I have new locations every seconds or so, but I never get the broadcast. MainActivity.java public class MainActivity extends Activity { private static final String TAG = "mainActivity"; private CMBroadcastReceiver mMessageReceiver = new CMBroadcastReceiver(); /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { // Start Service