android-service

Using the camera in Background Android

ⅰ亾dé卋堺 提交于 2019-12-01 10:45:14
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, "setPreviewDisplay " + e); } myCamera.startPreview(); } public void getFrames() { new Thread(new Runnable() { public

Exception on getSystemService(Context.AUDIO_SERVICE)

五迷三道 提交于 2019-12-01 10:14:39
问题 I wanted to create an app that drops an incoming call based on some settings, that seems to be impossible on Android 1.6. So I decided to write an app that changes the Ringer to mute when the call would've been dropped. The thing is that when I call getSystemService(Context.AUDIO_SERVICE) I get an exception. These are my classes: CallReceiver public class CallReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { MyPhoneStateListener

BroadcastReceiver issues in Android 3.1+

谁说我不能喝 提交于 2019-12-01 09:22:48
问题 I'm trying to update location data to a web database using BroadcastReceiver and Service . However I am having difficulties making it to work with Android 3.2 on a Galaxy Tab 7.0 Plus. The same application is working very well on a Android 2.3.6 Galaxy Note, but it doesn't run on the tablet. In fact, I add the RECEIVE_BOOT intent action to my receiver, but it never gets instantiated, that is, o nReceive() never gets called after boot completes. I wonder if there are any updates to the system

Show ProgressDialog in a Service class

*爱你&永不变心* 提交于 2019-12-01 08:51:08
I am using a Service to connect to a network using a AsyncTask. I want to show a ProgressDialog till the app is connected to the network. But how can I do this? My Service looks like this: package de.bertrandt.bertrandtknx; import tuwien.auto.calimero.link.KNXNetworkLinkIP; import tuwien.auto.calimero.process.ProcessCommunicator; import de.bertrandt.bertrandtknx.Controls.OnOff; import android.app.ProgressDialog; import android.app.Service; import android.content.Intent; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.AsyncTask; import android.os.IBinder

Foreground service not receiving location updates in Doze mode in Android O

╄→尐↘猪︶ㄣ 提交于 2019-12-01 08:21:18
I have a foreground service that needs to get a single location update. It is started by a specific broadcast, and upon starting it simply does a request on our backend. When it receives another broadcast, it requests a location update (once), does another backend request and then stops itself. Edit: to clarify, the service itself does the location updates and backend requests. It is independent from the main app in that regard. This works well on Lollipop and Marshmallow, both when the phone is awake or in Doze mode. But for some reason, on Android O the service never gets location updates

How can I save data from Android service?

房东的猫 提交于 2019-12-01 07:32:23
I have a service that collects data, can I save the data in case of reboot or any other action that will restart the service, and how can I do it? Can I save the data in case of reboot or any other action that will restart the service You will not necessarily find out when those sorts of events will occur. Save your data as you go. And how can I do it? Use a file. Or a database, which is a type of file. Or a SharedPreferences structure, which is backed by a type of file. Thilo-Alexander Ginkel You may want to make use of Android's SQLite3 support, which provides you with a lightweight

How to detect key-guard state in android

心不动则不痛 提交于 2019-12-01 07:17:17
I have an application that requires to detect the previous state of the key-guard before calling disableKeyguard() or reenableKeyguard() , set by the user! is there any way of accomplishing this task? From documentation Use ((KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE)).isKeyguardLocked() 来源: https://stackoverflow.com/questions/13986471/how-to-detect-key-guard-state-in-android

Foreground service not receiving location updates in Doze mode in Android O

风流意气都作罢 提交于 2019-12-01 07:01:25
问题 I have a foreground service that needs to get a single location update. It is started by a specific broadcast, and upon starting it simply does a request on our backend. When it receives another broadcast, it requests a location update (once), does another backend request and then stops itself. Edit: to clarify, the service itself does the location updates and backend requests. It is independent from the main app in that regard. This works well on Lollipop and Marshmallow, both when the phone

Android sending messages between fragment and service

喜夏-厌秋 提交于 2019-12-01 06:37:32
问题 I have a fragment with a button. When clicked it tells a service to start polling sensors and then insert the sensor data into a database on a background thread. When the button is pushed again, the service will stop. When the Stop button is pushed, there may still be tasks in the executor queue that is inserting into the DB, so during this time I want to display a progress dialog, and dismiss it once the entire queue is clear. The fragment with the button looks like this: public class

Show ProgressDialog in a Service class

一笑奈何 提交于 2019-12-01 06:07:57
问题 I am using a Service to connect to a network using a AsyncTask. I want to show a ProgressDialog till the app is connected to the network. But how can I do this? My Service looks like this: package de.bertrandt.bertrandtknx; import tuwien.auto.calimero.link.KNXNetworkLinkIP; import tuwien.auto.calimero.process.ProcessCommunicator; import de.bertrandt.bertrandtknx.Controls.OnOff; import android.app.ProgressDialog; import android.app.Service; import android.content.Intent; import android.net