Need code example on how to run an Android service forever in the background even when device sleeping, like Whatsapp?

NOTE: NOW THIS ANSWER IS ONLY VALID FOR ANDROID 7 AND BELOW. SINCE ANDROID 8 GOOGLE HAS CHANGED HOW BACKGROUND TASKS ARE HANDLED Since I posted this question, I have implemented two different approaches to this solution into multiple apps. APPROACH 1 This extract is from an app where I use push notifications, which need … Read more

Windows Service System.Timers.Timer not firing

Here is my work-around… After way too many hours searching for an answer to this, I discovered a wide variety of articles and blogs discussing timers in Windows services. I’ve seen a lot of opinions on this and they all fall into three categories and in descending order of frequency: Don’t use System.Windows.Forms.Timer because it … Read more

IIS w3svc error

Confirm that “Windows Management Instrumentation” is started and its start up type is set to automatic. Also make sure the following dependency services are started for World Wide Web Publishing Service: Windows Process Activation Service Remote Procedure Call (RPC) DCOM Server Process Launcher RPC Endpoint Mapper. Open regedit, navigate to [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP]: a) Double click on … Read more

How is an Intent Service Declared in the Android Manifest?

In your manifest you declare a service with android:name=”.Communication”, this means that your service class should be located in com.exercise.AndroidClient.Communication Check that the packages are correct. Note that the “.” (dot) refers to the root of your package (ie the package declared in the manifest). So, for example, if your package is com.exercise.AndroidClient and your … Read more

Does Android Service run from a separated thread instead of UI?

To clarify: The application’s main thread is not always the UI thread. For example: If an activity is stopped, the onStop() is invoked, hence the UI thread is taken away from that activity and moved to another activity within the same or a different application. However, it doesn’t mean that this application is no longer … Read more

onServiceConnected never called after bindService method

I’ve just experienced another version of this problem, with the same symptom of onServiceConnected(…) not being called. The cause was different in my case. You must make sure to have a service declaration in your AndroidManifest.xml within the application tag – this was the root of the problem for me. <application android:name=”.YourAppTitle” android:icon=”@drawable/icon” android:label=”@string/app_name”> <activity … Read more

Typescript generic service

You can create an abstract generic class and two children class that inherits from it : abstract class: export abstract class AbstractRestService<T> { constructor(protected _http: Http, protected actionUrl:string){ } getAll():Observable<T[]> { return this._http.get(this.actionUrl).map(resp=>resp.json() as T[]); } getOne(id:number):Observable<T> { return this._http.get(`${this.actionUrl}${id}`).map(resp=>resp.json() as T); } } driver service class @Injectable() export class DriverService extends AbstractRestService<Driver> { constructor(http:Http,configuration:Configuration){ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)