android-service

Get screenshot of current foreground app on Android having root priviliges

只谈情不闲聊 提交于 2019-12-02 19:46:01
问题 I'm developing an application that is installed on the system partition and I would like to know if it's possible to get a screenshot of the current foreground application from a service. Of course, the application being any third party app. I'm not interested in security issues or anything related to that matter. I only want to get a snapshot of the current foreground third party app. Note: I'm aware of the /system/bin/screencap solution but I'm looking for a more elegant alternative that

Bind to service from new Context for configuration changes or bind from app context?

不想你离开。 提交于 2019-12-02 19:37:24
I'm trying to work out if bound service is appropriate for doing background work in my app. The requirements are that various application components can make web requests through it of varying priority. (Thus the service must maintain some sort of queue and be able to cancel it's ongoing requests for others of higher priority). I'd like the service to be relatively unobtrusive to the user such that they don't find it running after they are done with the application - if I want to do something more important that continues while the application is closed I can use startForeground() to push a

BoundService + LiveData + ViewModel best practice in new Android recommended architecture

本小妞迷上赌 提交于 2019-12-02 19:10:50
I been struggling a lot thinking about where to place Android Services in the new Android recommended Architecture . I came up with many possible solutions, but I cannot make up my mind about which one is the best approach. I did a lot of research, and I couldn't find any useful guideline nor tutorial. The only hint I found about where to place the Service in my app architecture is this one, from @JoseAlcerreca Medium post Ideally, ViewModels shouldn’t know anything about Android. This improves testability, leak safety and modularity. A general rule of thumb is to make sure there are no

How to transfer files between Android applications running on the same device?

て烟熏妆下的殇ゞ 提交于 2019-12-02 17:33:42
I am writing an Android application that interfaces with a RESTful service. This web service essentially fronts a file system, and provides metadata as well CRUD access to the files. My application retrieves the metadata, and exposes it to 3rd party apps through a ContentProvider . I need to add the ability for 3rd party applications, running on the same device as my app, to CRUD the actual files by making requests to/from my app (not directly with the server). This means they need to either send or receive the contents of the files (which are typically XML or images) through my app. I have

onPictureTaken never called

眉间皱痕 提交于 2019-12-02 17:33:35
问题 The code works mostly fine. The only problem is that the onPictureTaken function never called. I need to use this function to store the image to SD Card. MainActivity public class MainActivity extends Activity { //private static Camera mCamera; //private CameraPreview mPreview; private static String TAG = "CamraOne"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera_layout); Log.d(TAG, "setContentView end"); Intent

how to start service from fragments

怎甘沉沦 提交于 2019-12-02 17:31:54
I want to start service from fragment from a list view item. I am trying to call service with: startService(new Intent(getActivity(),myPlayService.class)); But it wont work at all. How do i call my service from fragments? Is there any another way to start service? Replace startService(new Intent(getActivity(),myPlayService.class)); with getActivity().startService(new Intent(getActivity(),myPlayService.class)); 来源: https://stackoverflow.com/questions/13007355/how-to-start-service-from-fragments

How to perform notification-action (click) on lock-screen?

旧巷老猫 提交于 2019-12-02 16:18:35
TL;DR How can I make a notification that does some work from the lock-screen without unlocking? After clicking an action, a button on the notification or just the complete notification, I want to do an API call (without typing my unlock code) Details Goal Based on the answer on this question I tried to make a notification with an action that works on the lockscreen without unlocking the device. The action is something that doesn't need any further interface or interaction (think 'send an API request'). Status The notification and click do work with an unlocked device. However, when locked I

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

社会主义新天地 提交于 2019-12-02 15:44:26
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 novice with Android so it's still hard to figure it out. I see Google uses RemoteHandlers to process

Couldn't get user location

两盒软妹~` 提交于 2019-12-02 14:34:46
问题 I am trying to get user location either network location or gps location or both. for that i am running a background service which implements LocationListener . i added all the require permissions in the manifest file also. here is my service public class GetLocation extends Service implements LocationListener { LocationManager lm; Location networkLocation, gpsLocation; @Override public void onCreate() { super.onCreate(); lm = (LocationManager) getSystemService(LOCATION_SERVICE); if (lm

Why does my Android service get restarted when the process is killed, even though I used START_NOT_STICKY?

大兔子大兔子 提交于 2019-12-02 13:54:26
My app uses a pattern where I start a service with Context#startService() as well as bind to it with Context#bindService() . This is so that I can control the lifetime of the service independently from whether any clients are currently bound to it. However, I noticed recently that whenever my app is killed by the system, it soon restarts any services that were running. At this point the service will never be told to stop, and this is causing battery drain whenever it happens. Here's a minimal example: I found someone with a similar issue here , but it wasn't ever diagnosed or solved. Service: