android-service

Android Broadcast Receiver vs Service [duplicate]

末鹿安然 提交于 2019-11-28 13:56:55
问题 This question already has an answer here: BroadcastReceiver vs Service 2 answers I am trying to clarify the difference between a Broadcast Receiver and Service in android. I understand that an activity can start a service by calling startService with an intent. A broadcast receiver can be registered in code or the manifest and can be called with sendBroadcast . When would you use one vs the other? I understand that multiple broadcast receiver's can be listening for the same intent and this is

Passing information to a HostApduService from another Context

浪子不回头ぞ 提交于 2019-11-28 13:49:47
This has been asked before with no responses, so I will try to phrase the question a bit differently. What are the various ways to pass some data to an Android Service without being able to bind to it or start it myself? Here's the issue - I have a HostApduService that is started by the operating system on every NFC card transaction. It requires the permission android.permission.BIND_NFC_SERVICE , which is a system permission, so my application can't bind to it. I don't want to leave data at rest so anything that gets written to the disk is a no-go. I thought of a few possible solutions, but

Schedule a TimerTask at specific time once per day in a service in android

我的梦境 提交于 2019-11-28 13:11:06
I have a TimerTask object timerTask . My code is running but when service gets started initially, my timer task runs instantly before the specified time i.e. 3:30 PM, though I want it to run on 3:30 PM once per day only. Calendar cal = Calendar.getInstance(); cal.set(Calendar.AM_PM, Calendar.PM); cal.set(Calendar.HOUR, 3); cal.set(Calendar.MINUTE, 30); cal.set(Calendar.SECOND, 0); Date date = cal.getTime(); timer.schedule(timerTask, date, 1000*60*60*24); // once per day As other community users suggested, don't use Timertask, android has a AlarmManager that you can use. HOW? Register the alarm

How do I keep running a Service the whole time?

∥☆過路亽.° 提交于 2019-11-28 12:51:25
I have some process that I would like to run in the background the whole time. So I made it a Service . My question is: is there anyway to prevent from the user from killing this service? (even if he uses third party app) No, it is not possible . It is also a bad idea . Maybe this can help you: final Intent intent = new Intent(context, YourService.class); final PendingIntent pending = PendingIntent.getService(context, 0, intent, 0); final AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarm.cancel(pending); long interval = 30000;//milliseconds alarm

Can I prevent Host Card Emulation service from being triggered by select AID?

偶尔善良 提交于 2019-11-28 12:50:55
I have an Android app with a service registered to Android beam and a service registered to host card emulation. I want to decide when to enable/disable the HCE service in the code. The HCE service in the manifest looks like this - <service android:name="com.bimo.verifonewallet.service.MyHostApduService" android:exported="true" android:permission="android.permission.BIND_NFC_SERVICE" > <intent-filter> <action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE" /> </intent-filter> <meta-data android:name="android.nfc.cardemulation.host_apdu_service" android:resource="@xml

android camera in background

点点圈 提交于 2019-11-28 12:46:29
I am developing an application to take images from background application say using android service. i don't want any user interaction to takes images, it should completely work from background. I have already tried - Calling camera from service - It not always works sometime works if we have dummy surfaceview, again if Android close the related activity service stopped takings pics, I don't want to run activity for user interaction. with some changes it working fine but all images are black. Widget: Not getting how to call camera in widget as widget doesn't support surfaceview. Live wallpaper

How can location updates from FusedLocationProviderClient be processed with Work Manager?

这一生的挚爱 提交于 2019-11-28 12:36:49
First of all, I'm a total Android noob. Have looked for solutions for some time now, but can't find any helpful hints in the right direction so far. This might be generally caused by the nature of the issue itself, being quite niche. The working code below is based on a code lab at https://codelabs.developers.google.com/codelabs/realtime-asset-tracking . I was wondering though, since it was mentioned within several resources as the preferred way now, how you'd do something like that based on Android's Work Manager instead of a Service with an ongoing notification? public class TrackerService

Android Service can be bind without start?

冷暖自知 提交于 2019-11-28 11:38:32
In many articles, tutorials, docs, have read so far, that we call startService() or bindService(), both starts the service. We can call both also, but that's a different story. I am unable to bindService without startService(). private void bindTunManagerService(int flags) { TunnelManagerService.setParentActivity(this); Intent bindIntent = new Intent(this, TunnelManagerService.class); startService(bindIntent); tunManagerServiceStarted = bindService(bindIntent, tunConnection, BIND_AUTO_CREATE); Log.d(TAG, "tunManagerServiceStarted : " + tunManagerServiceStarted + ", ** tunManagerService = " +

android broadcast receiver (call and sms received) not working in android nougat

不羁岁月 提交于 2019-11-28 09:52:10
问题 android call and SMS broadcast receiver working perfectly till marshmallow 6.0, but in android nougat , it is not working when app is closed, and when app is in background, then its working fine in android nougat(N). please can anyone help me for this issue. public class CallReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals("android.intent.action.NEW_OUTGOING_CALL")) { savedNumber = intent.getExtras().getString(

Unable to start service Intent: not found

馋奶兔 提交于 2019-11-28 09:38:20
I've the same issue described here but i can't understand whats wrong. My issue is: Unable to start service Intent { act=.connections.MoodyService } U=0: not found EDIT I've changed my package from connections to service in the source code, sorry for the confusion My manifest.xml <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.moody" android:installLocation="auto" android:versionCode="0" android:versionName="0.6.7 alpha" > <uses-sdk android:maxSdkVersion="18" android:minSdkVersion="14" android:targetSdkVersion="17" /> <uses-permission android:name=