Posts

Showing posts with the label service

Communicate with Activity from Service (LocalService) - Android Best Practices

Image
Clash Royale CLAN TAG #URR8PPP Communicate with Activity from Service (LocalService) - Android Best Practices Common scenario - Activity with a background Service to poll server. The Service will run periodically via AlarmManager and also perform tasks for the Activity (user hits a button, go fetch something from server). I'd like to know the best practices here. I think the best design would be the Android LocalService example: http://developer.android.com/reference/android/app/Service.html#LocalServiceSample However in the example the Activity has a reference to the activity mBoundService but there is no reverse connection ( the Service has no way to call the Activity ). mBoundService What is the best way for the Service to call the Activity? Do I use Intents, BroadcastReceivers, Messages? How? 3 Answers 3 I think the best design would be the Android LocalService example: http://developer...

Android Service no Inicia

Image
Clash Royale CLAN TAG #URR8PPP Android Service no Inicia Hola amigos, estoy tratando de que mi App ejecute un servicio en segundo plano, actualmente logro hacer que funcione pero al eliminar la app desde las app abiertas se elimina y no logro hacer que ese servicio se vuelva ejecutar. EL ejemplo con el que les pongo aqui reproduce un audio aunque a futuro lo que haré será sustituirlo por un metodo que realize salvas de la BD de mi app. Básicamente lo que necesito es ayuda para saber que mi proceso se está reiniciando una vez de cerrad mi app. aqui les muestro mi código y me digan porque no logro hacer que reinicie nuevamente el servicio. MI layout contiene esto. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match...