android-service

Android Service not receiving Message from Activity

随声附和 提交于 2019-12-13 05:46:30
问题 I have created both a Service and an Activity that need to be able to communicate with each other. The Activity should send a Message to the Service, and the Service should reply with a result. The problem is that the Message doesn't seem to be making it to the Service. This is the output to the log from the code: 02-07 18:26:37.057: I/Task Timer(8850): Service bound 02-07 18:26:37.097: V/Task Timer(8850): Service connected: ComponentInfo{com.gawdl3y.android.tasktimer/com.gawdl3y.android

How 3rd party app obtains my custom defined service permission to start my service?

怎甘沉沦 提交于 2019-12-13 05:42:17
问题 Here is my manifest file with my background service declaration ...... <service android:name="com.example.MyService" android:process=":service" android:permission="android.permission.BIND_VPN_SERVICE"> <intent-filter> <action android:name="com.example.START_MY_SERVICE" /> </intent-filter> ...... What should a 3rd party app declare in its manifest which is interested in binding with my service ? Also how does the verification of the permission( or custom defined permission) happens in my app

Return http request result to an activity

一世执手 提交于 2019-12-13 05:24:35
问题 I have to develop an Android application that perform a http GET request to a server that responds with a JSON string. Because I need to do that request more times in the app I've created a class only to do this task using AsyncTask . The problem is that I'm not able to return the JSON sting from the AsyncTask to the activity and reading some question I've understood that the AsynkTask isn't the solution, so I've tried to perform the request using an Android Service but I got a

Start service every 10 seconds

 ̄綄美尐妖づ 提交于 2019-12-13 05:19:58
问题 I have this android service that I'm trying to get information from every 10 sec, for testing purposes. But from what I can see service is starting but not getting update from it every 10 second. What can be the problem? Here is my service: public class SimpleService extends Service { private static final int NOVI_VESTI = 1; private static final int NOVA_OGLASNA = 2; private List<String> titles; @Override public IBinder onBind(Intent arg0) { return null; } @Override public int onStartCommand

Intent Service do not get started when called from a broadcast receiver

こ雲淡風輕ζ 提交于 2019-12-13 04:34:44
问题 I am working on an app in which on receiving a message i need to start a service. But my Intent service is not running. Here is what I am doing: Broadcast Receiver: public void onReceive(Context context, Intent intent) { this.con=context; Toast.makeText(context,"Broadcast received", Toast.LENGTH_LONG).show(); Bundle bundle = intent.getExtras(); Object[] messages = (Object[])bundle.get("pdus"); SmsMessage[] sms = new SmsMessage[messages.length]; for(int i=0;i<messages.length;i++) { sms[i] =

Prevent that the app get stopped or paused by the OS

我的未来我决定 提交于 2019-12-13 04:31:03
问题 I'm developing and Android application on CodenameOne that needs to send a web request every 5 minutes even when minimized. How can I achieve this behavior in order to prevent that the request get stopped or paused by the OS? 回答1: You cant do that from the activity, you'll need to create background service. http://developer.android.com/training/run-background-service/create-service.html 回答2: Use AlarmManager to set up your every-five-minute operation. Have it trigger a BroadcastReceiver ,

Example: Communication between Activity and Service using Messaging

假如想象 提交于 2019-12-13 03:57:20
问题 I couldn't find any examples of how to send messages between an activity and a service, and I have spent far too many hours figuring this out. Here is an example project for others to reference. This example allows you to start or stop a service directly, and separately bind/unbind from the service. When the service is running, it increments a number at 10 Hz. If the activity is bound to the Service , it will display the current value. Data is transferred as an Integer and as a String so you

AndroidX Work Library is canceling operations, seemingly without reason

旧城冷巷雨未停 提交于 2019-12-13 03:47:52
问题 I am working with the AndroidX Work Dependency to try and run some background service operations. I am currently running the most recent stable version, 2.2.0 as of posting this question. The actual operation I am running in the background is a fairly heavy-CPU operation as it is using some compression code in one of my libraries (here) and can take anywhere from 3-30 minutes depending on the size and length of the video in question. Here is the code I have that builds and runs the work

Android Service not getting start from JobIntentService on BOOT

[亡魂溺海] 提交于 2019-12-13 03:30:03
问题 I am trying to run a service on OREO device and service get started as it listens to android.intent.action.BOOT_COMPLETED intent. Below is Boot Received Broadcast Reciever class: public class ConnectionBOOTReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { MyIntentService.enqueueWork(context, new Intent()); } } Below is my IntentService Class: import android.content.Context; import android.content.Intent; import android.support.annotation

Start native service at early-init before coldboot done

强颜欢笑 提交于 2019-12-13 03:11:14
问题 Boot sequence in Android is defined via system/core/rootdir/init.rc and other *.rc files. Such approach allows to bind any action to any boot stage ( early-init , init , etc). Also in system/core/init/init.cpp is defined the following sequence of the boot: - ... ; - early-init ; - wait_for_coldboot_done ; - ... ; - init ; - ... . It means that some action inside imported *.rc file binded to the early-init stage can be started before coldboot (and SELinux initialization) will be finished by