android-service

use registerReceiver for non activity and non service class

三世轮回 提交于 2019-12-20 02:29:36
问题 I am trying to registerReceiver for BluetoothDevice events like ACTION_ACL_CONNECTED , ACTION_ACL_DISCONNECTED . But the class in which I am using registerReceiver does not extend Activity class nor Service class - so I am passing Context to that class and registering receiver as follows context.registerReceiver(ActionFoundReceiver, new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED)); context.registerReceiver(ActionFoundReceiver, new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECTED));

Call onDestroy() of Service

偶尔善良 提交于 2019-12-19 20:48:04
问题 I want to call onDestroy() method of Service in android. I already searched a lot on internet and many answers are like if service force stop or somehow its onDestroy() will never call. But I really need to know when service is stop. My project is about music player. So it uses service and there is an ongoing notification. I need to find out when the service stop? and need to stop the music and remove the notification. But it never shows any log of onDestroy() . Can anyone help me what is the

Can a bundle be passed to a service?

与世无争的帅哥 提交于 2019-12-19 17:36:14
问题 In my application i need to get a value from an activity to a service. The value that i need to retrieve is the one i clicked in that activity. For eg: If i select x[i] element from Activity A, i need to retrieve the value x[i] in a Service S. How is it possible? Thanks, Niki 回答1: In the service use this: public int onStartCommand (Intent intent, int flags, int startId) { super.onStartCommand(intent, flags, startId); Bundle bundle = intent.getExtras(); } 回答2: When you create an intent , you

How to communicate between background services

Deadly 提交于 2019-12-19 11:36:05
问题 I am implementing an app, in that I have two Services. One does some task and pass some value to another service and that service does some task using this value. When the first Service generate first value it should start 2nd service. Here after the values generated by the first service will be added in a queue in 2nd service. First time when the 2nd service starts I can set the value in queue using intent, but I don't know how to communicate after starting the 2nd service. How to

How to show an actitivity only when an app widget is first created?

ぃ、小莉子 提交于 2019-12-19 10:58:20
问题 My app widget needs to be configured when it first added to the home screen. I want to open a configuration view right after the user adds the widget. AppWidgetProvider has no onCreated event, so I'm showing the confugration activity on the onUpdate event, and store a boolean value in SharedConfiguration that marks that the configuration has already been shown. Is there an easier way? 回答1: In the AppWidgetProvider XML file there is an attribute called android:configure You can use this to

How to stop my service?

放肆的年华 提交于 2019-12-19 10:52:53
问题 Please also see Edit 2 (below) I have extended NotificationListenerService and implemented several of its methods including the onDestroy() method (but not the onBind() or onStartCommand() method, as I don't need them, as far as I know). However when I call selfStop() onDestroy() isn't called. I know there are other links out there about calling selfStop() , but I haven't found any solution for my problem. My service is started by the system using the following code in the android-manifest :

Using the camera in Background Android

江枫思渺然 提交于 2019-12-19 10:11:37
问题 I'm trying to get the picture into service from Camera. @Override public void onCreate() { super.onCreate(); //android.os.Debug.waitForDebugger(); myCamera=Camera.open(); SurfaceView dummy=new SurfaceView(getApplicationContext()); try { if(myCamera!=null) { myCamera.setPreviewDisplay(dummy.getHolder()); myCamera.setPreviewCallback(this); Log.i(TAG,"myCamera is not null"); } getFrames(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); Log.e(TAG,

Is the Application class guaranteed to be instantiated before a defined boot receiver is called

一世执手 提交于 2019-12-19 06:19:37
问题 Excuse me for such an elementary question. I understand that the Application class is instantiated when my app's process starts and I understand when the phone is completed booting my boot receiver will be called. I'm assuming since the phone knows via the manifest that my app holds BOOT_COMPLETED intent filter, the reboot process is. Phone reboots, phone starts all processes with BOOT_COMPLETED, phone fires off BOOT_COMPLETED broadcast. My concern came from wondering if I reference

Building an Android APK with same certificate as the system

若如初见. 提交于 2019-12-19 04:59:14
问题 I'm trying to make a system app work. Here's what I have: An OEM OMAP platform with full 4.4.2 source code. I've built the system and loaded on my platform using Ubuntu 14.04. That all works. Now, there is an app from the OEM which directly accesses the hardware (DSP, I2C, UART) etc. The original APK that came from the OEM works on my platform. I built the exact same app using make command (not using Eclipse); It builds and I can install on the platform. But when I try to launch the app, it

Android Local Service Sample, bindservice(), and ServiceConnection()

本秂侑毒 提交于 2019-12-19 04:18:29
问题 I have a question which is related to this question that was asked by @mnish about a year ago. Please have a look at his question and code. He implements a ServiceConnection() and passes it to bindService(). This follows the Local Service Sample in the Service documentation near the top. I want to implement the Local Service Sample, so I am trying to add some details from @mnish question/answer. In ServiceConnection() @mnish has this line that confuses me: mService = ILocService.Stub