android-service

Several services, Same Android app

拟墨画扇 提交于 2019-12-12 04:33:15
问题 I currently maintain an Android application which uses a big fat services handling : Bluetooth communication (constant through App usage) File compression Http Request Canvas saving (the app uses Samsung Pen SDK, with huge canvas to save) I'd like to split the service into new namely services. Should I? Am I going to slow my app by using too much memory for those services? Is it going to be mess to maintain? Thx in advance 回答1: If managed properly several services can decrease memmory and CPU

Launching already running activity from service intent

折月煮酒 提交于 2019-12-12 03:56:47
问题 RE: Move back to App after launching another App and Launching Intent from service causes crash I now have the terminal launching correctly from my service, however my next step is to, after the service has launched the terminal intent to relaunch the apps main activity. I am doing this using: public void backtoEmplayer(){ Intent intenti = new Intent(MainService.this,MainActivity.class); intenti.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intenti.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);

Keep Android service running even after Activity is closed

会有一股神秘感。 提交于 2019-12-12 03:49:23
问题 I am building one of those SOS apps. Whenever the device is shaken above a threshold value (detected through accelerometer), I am showing a Toast (as of now) 1) App is launched. User gives name, email, etc.. and clicks finish on last screen. 2) Service is started which keeps listening for shake. 3) It detects the shake correctly if the App is running. 4) If I close the app (the activity ), the service gets killed along with it. How do I keep the service running even if app is closed, so that

Cannot access notification through Android AccessibilityService

非 Y 不嫁゛ 提交于 2019-12-12 03:34:11
问题 I am trying to access the notifications on my android phone using the AccessibilityService. I tried making a service and calling it from the main activity. I've also added meta for the service. It's not working. I cannot see the triggering of the service. I'm using Android L for testing. In accessibility settings I've added my app 'Notify' as on. Thanks in advance. My main Activity package com.example.tony.notify; import android.content.Intent; import android.provider.Settings; import android

onLeScan function not called when trying to detect BLE devices

感情迁移 提交于 2019-12-12 03:09:01
问题 I am trying to detect nearby Bluetooth Low-Energy devices on a service. When the service is started, startLeScan() is called, and then stopLeScan() is called after 10 seconds. Even though startLeScan() returns true, and I didn't get any error, onLeScan on the LeScanCallback was not called. the Service : . . . // Device scan callback. private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback() { public void onLeScan(final BluetoothDevice device, final int

How to Get data from Service to Activity where Callback is Involved?

依然范特西╮ 提交于 2019-12-12 03:08:44
问题 Here's the scenario, I want to get Data from the Service to Activity Whenever The Service gets new data from the server, the following function(callback) gets automatically called public void publishArrived(blah, blah) { //some operation here } How to I get the Data got from the above function back to my activity ? (I think I am supposed to use "Messenger" here but i am not able to grasp the concept) CONTEXT : In my activity i Perform a Login operation whose success depends on the above

Can't register more than one Sensor in Android Service

前提是你 提交于 2019-12-12 02:36:08
问题 I have a service which is called from an Activity. This Service Registers all Sensors and Registers Listener against them. EDIT: I have removed the two lines in onSensorChange() **sensorManager.unregisterListener(this); sensorManager = null;** AND now it works. WHY? The Problem is that when I do them one at a time, my application works fine but if I register more than one sensor, My application crashes. Here is the OnCreate Function of my Service: @Override public void onCreate() { super

Prevent Android Service From Being Killed By OS

ぃ、小莉子 提交于 2019-12-12 02:36:00
问题 I have created a service that is returning START_STICKY at the onStartCommand. However, after sometime, I notice that my app has been killed by the OS. Is there any method/piece of code that I can use to prevent the app from being killed by the OS? I know this may not fall under the best practices. Or is there some other method that we can use like repeatedly check if the app is running, and to start the app if it is not? Your insight on this is very much appreciated. Cheers 回答1: You cannot

GcmListenerService is not called while application stopped. Android GCM

妖精的绣舞 提交于 2019-12-12 02:31:46
问题 My manifest file is as below: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.app"> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="com.google.android

Call multiple services in background in android

老子叫甜甜 提交于 2019-12-12 02:24:09
问题 I have to call multiple services in background for a project in android app. In each services i have to call separate web service and get some data and process it with local sqlite database. I am able to call each service separately and can manipulate its result with local database. But not able to call all services in a sequence. my code is as below: @Override public void onStart(Intent intent, int startid) { Toast.makeText(this, "My Service Started", Toast.LENGTH_LONG).show(); Timer timer =