android-service

How to run background service for Instant Messaging using Kurento API in Oreo?

天涯浪子 提交于 2019-12-25 00:33:52
问题 Android Oreo has released with many restrictions on running background services/Task. Services now don't behave like normal in Oreo as they used to before. But what if I have to run a service in background for 24*7 for Instant Messaging. I am developing an application for Instant messaging using kurento Third Party API. To achieve this I will have to run a background service which communicate with server for new messages. Lower then Oreo its working fine. How do I prevent android system to

how to know our app has gone to background in android

放肆的年华 提交于 2019-12-25 00:26:39
问题 When user goes to other apps from my app or presses device home button from my app or etc , then my app will be sent to background. And in the background am doing some stuff . So how to know is my app has gone to background . One solution will be to check if any of app activities are in onstart,onrestart,onresume,onpause,onstop if not then we can consider it in background. But this solution is tedious please help me if you have a easy solution 回答1: Using onPause isn't tedious, and may be your

Android service is restarting slowly

邮差的信 提交于 2019-12-24 23:45:21
问题 I have created a service and returned "START_REDELIVERY_INTENT" in "onStartCommand()" method, as i want to run the service even after destroying the App's MainActivity. App should restart just after destroying the App with previous non-null intent. But App is taking some time to restart. We can see the status of restarting App in device setting (Below is snapshot). This snapshot is after destroying App..... What i do? Any Help please? public int onStartCommand(Intent intent, int flags, int

How can start Service several times while Service is alive

本秂侑毒 提交于 2019-12-24 20:19:36
问题 I want to do this acts with my Service : 1)start App 3)start a Service by App 4)update my UI by Service 5)close App but the Service keep work 6)sart App again 7)connect to Service (not run new Service) I want in my service public variable during living Service do not change. 回答1: If you return START_STICKY from onStartCommand() then your Service will run unstil it is explicitly stopped. You can then decide how you want to stop your Service , either by something calling stopService() or by the

How to Remove an unused GcmTaskService service?

风流意气都作罢 提交于 2019-12-24 16:28:41
问题 I have this code GcmTaskService service code that check internet is ok to push some data online : public class NetworkChangeService extends GcmTaskService { public static String TAG = "NetworkChangeService"; private static long ONE_HOUR_IN_SECONDS = 3600L; private static long ONE_MINUTE_IN_SECONDS = 60L; private Synchronizer synchronizer; public NetworkChangeService() { } @Override public int onRunTask(TaskParams taskParams) { // do my task here like syncing stuff Log.d(TAG,

Android Music Player Service not playing after home/back button is pressed

二次信任 提交于 2019-12-24 14:03:48
问题 Am trying to write music player code in android.I wrote the MediaPlayer code in a service.Here is the code: package com.example.audioservice; import android.app.Service; import android.content.Intent; import android.media.MediaPlayer; import android.os.IBinder; import android.util.Log; public class MyService extends Service { static MediaPlayer mp; @Override public void onCreate() { // TODO Auto-generated method stub super.onCreate(); System.out.println("in MyService onCreate()"); mp

Synchronizing data between SQLite (Android) and MS-SQL (Hosting)

我们两清 提交于 2019-12-24 13:52:57
问题 I need to Synchronize some tables between the App SQLite Database an a MS SQL Database hosted online. I already have a COLUMN (IsSync) on each table that allows me to know which ROWS are pending sync (i.e. SELECT * FROM Locations WHERE IsSync=0) The Locations table is one of the tables that I need to synchronize as soon as the table got updated/inserted. This table contains GPS Location data (Lat,Lng,Accuracy,Speed, etc) that is inserted EACH AND EVERY 3-4 SECONDS (15 records each minute).

Access shared preference from a service

[亡魂溺海] 提交于 2019-12-24 12:44:10
问题 I am fairly new to android. I have an activity in my application. I used shared preferences to store some data related to that activity. Now, how can I access those stored data from another service class? Is it possible? Your attention is highly appreciated. 回答1: Seeing as you're already in an application component that extends Context, you can simply use: SharedPreferences prefs = this.getSharedPreferences("Pref name", Context.MODE_PRIVATE); Make sure you call this in or after onCreate() .

Managing SharedPreferences in both PreferenceActivity and Service within same app

六眼飞鱼酱① 提交于 2019-12-24 12:03:11
问题 I'm building an app with a PreferenceActivity and a Service (running in its own remote process due to android:process=":remote" flag) and both need to access programmatically the SharedPreferences . At present time I'm getting a SharedPreference object with the following code that uses the getSharedPreferences method defined in both Service and PreferenceActivity classes: SharedPreferences sharedPrefs = getSharedPreferences("com.mypackage_preferences", MODE_PRIVATE, MODE_MULTI_PROCESS) Is

onAdjustVolume not called

浪子不回头ぞ 提交于 2019-12-24 10:37:01
问题 I am trying to get HARDWARE_HOOK button and volume change button in my service using MediaSession for Android 5.0+ . This has to work specially when screen is off/locked. The problem is that though I am able to receive HARDWARE_HOOK button event, the volume change is not detected. the onAdjustVolume method never gets called. import android.app.Service; import android.content.Intent; import android.media.MediaRouter; import android.media.session.MediaSession; import android.os.Binder; import