android-service

Started activity from home key screen

大兔子大兔子 提交于 2019-12-04 12:46:25
I have a background Service which starts an activity, Intent i = new Intent(this, MyActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(i); After destroying this Activity and restart it over the "long press home key menu", this Activity starts again. But I want to start the main activity instead. How could I realise this? Could you explain in more detail? If I understand your problem try setting the FLAG_ACTIVITY_NO_HISTORY. Alternatively a manual solution would be to check the FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY on the intent in MyActivity and launch to the main activity

java.lang.IllegalAccessError class ref in preverified class resolved to unexpected implementation

余生颓废 提交于 2019-12-04 11:27:41
Im getting an "java.lang.IllegalAccessError class ref in preverified class resolved to unexpected implementation" error when I push a button that starts a method in MainActivity which is supposed to start a new Activity. What can I do to fix this? This is my first attempt to make an android application, so ill need step by step instructions :) Also I havent been able to test if it works yet, but if you notice anything wrong with my AugiActivity service implementation or the local broadcast implementation feel free to let me know. Thanks! fyi: MainActivity starts Navigation Activity, which

Android geofencing when app is killed

孤人 提交于 2019-12-04 11:05:45
My main requirement would be to have a service having its own process and trigger its own geofencing event. I'd like the user to be notified from the notification center when he enters a geofence, even if the app is killed. I read about services and this seems pretty clear to me, the Android documentation is dense so I managed to understand how to start a service with its own process, and also how it is able to communicate with the app using Messenger. Then there is this code sample from Google showing how to use geofencing with google play services: Google samples geofencing What I found so

Foreground service gets killed on performing internet related operations

守給你的承諾、 提交于 2019-12-04 10:42:12
问题 UPDATE: Previously I couldn't find a well defined pattern as to when my foreground service was being killed. After more debugging with the devices (doesn't happen on all) on which this was happening I found. 1.) A lot of times when I open chrome to load a website the foreground service gets killed. Sometimes even when I am using whatsapp this happens. 2.) There are no exceptions and the stacktrace doesn't show anything useful. Original Question below: There are many such questions on

Using Service, TimerTask and BroadcastReceiver to check for various updates

六眼飞鱼酱① 提交于 2019-12-04 10:34:26
I'm trying to create a simple program that does the following: A service (NewsService) started by my activity (UpdateServiceActivity) checks for news. If news are found (NewsService) sends a broadcast to a receiver (NewsReceiver). Upon receiving the broadcast the receiver (NewsReceiver) should notify the activity (UpdateServiceActivity) that there are news. Upon notification, the activity (UpdateServiceActivity) gets the news and handles them. So far I'm just working on a simple example. Here is my code so far: UpdateServiceActivity public class UpdateServiceActivity extends Activity

Android: Foreground service vs. wakeLock

帅比萌擦擦* 提交于 2019-12-04 10:17:47
问题 I am relatively new to Android, so what I am asking may seem obvious (although I have read all the similarly titled questions, and have searched extensively). I need to monitor the accelerometer continuously for long periods. Two approaches have been suggested: 1) acquire a partial wake lock that is held the entire time the acceleromtere is being monitored; and 2) monitor the accelerometer in a foreground service. The first approach appears to use a lot of battery life. The second approach

how to prevent service to run again if already running android

放肆的年华 提交于 2019-12-04 09:52:25
问题 On click of a button I want to start service using method startService(new Intent(currentActivity.this,MyService.class)) but if service is running I don't want to call this method to avoid run service that is already running.How this is possible.I am using both Intent service and Service in same project and want to apply same condition for both. 回答1: A service will only run once, so you can call startService(Intent) multiple times. You will receive an onStartCommand() in the service. So keep

How to communicate with HostApduService from an Activity

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 09:52:13
I have asked this question here but it was marked as duplicate - however I didn't find any solution helpful mentioned in comments. Here, I am asking again with more details ... I am doing a sample app (PoC) on HCE and using HostApduService as per Android user guide. I have created two apps 1) ReaderApp - acting as card reader 2) HCEApp - emulating a card In HCEApp, I have created a class 'MyService' extending HostApduService public class MyService extends HostApduService { private int messageCounter; private final String TAG = "MyService"; Intent mIntent; @Override public void onCreate() {

Take a screenshot - Background Service

纵然是瞬间 提交于 2019-12-04 09:30:13
I'm trying to take a screenshot using a background service. This service is like a Facebook chathead, but I want it to take an screenshot when I do a click. Preview Picture I've developed some code but it doesn't work. The last I've tried was: private void takeScreenshot() { Date now = new Date(); android.text.format.DateFormat.format("yyyy-MM-dd_hh:mm:ss", now); // image naming and path to include sd card appending name you choose for file String mPath = Environment.getExternalStorageDirectory().toString() + "/capture/" + now + ".jpg"; // create bitmap screen capture Bitmap bitmap; View v1 =

Why would I use a Bound Service?

六眼飞鱼酱① 提交于 2019-12-04 09:12:36
For communicating between the application and a Service, why would I use a Bound service rather than sending data in the Intent: mServiceIntent = new Intent(getActivity(), RSSPullService.class); mServiceIntent.setData(Uri.parse(dataUrl)); I read that "If the service is already running, it will be called with onStartCommand() again, to deliver the new Intent, but a second copy is not created." Which means that I Could send messages in that intent to affect the service's progress, this is what is done in the google RandomMusicPlayer example: public void onClick(View target) { // Send the correct