android-service

Android: AlarmManager used to call a Service to notify the user

我的未来我决定 提交于 2020-02-02 12:32:11
问题 Edit Adding this line in my manifest solved my problem (the Service is well created). <service android:name=".TimersService" > Post I'm currently trying to implement alarms to notify the user that a countdown has finished. I have a method createAlarm() that adds a new Alarm through an AlarmManager . This method is currently called inside a Fragment. It looks like this: private final void createAlarm(String name, long milliInFuture) { Intent myIntent = new Intent(getActivity().getApplication()

Android: AlarmManager used to call a Service to notify the user

女生的网名这么多〃 提交于 2020-02-02 12:31:05
问题 Edit Adding this line in my manifest solved my problem (the Service is well created). <service android:name=".TimersService" > Post I'm currently trying to implement alarms to notify the user that a countdown has finished. I have a method createAlarm() that adds a new Alarm through an AlarmManager . This method is currently called inside a Fragment. It looks like this: private final void createAlarm(String name, long milliInFuture) { Intent myIntent = new Intent(getActivity().getApplication()

How can a remote Service send messages to a bound Activity?

房东的猫 提交于 2020-01-31 08:54:01
问题 I've read the documentation about Bound Services, where it is shown that you can easily communicate through Messages from an Activity to a remote (i.e. not in the same context) Service but is there any way to send messages from the Service to the bound Activity ? For example, my activity bounds to a running background service of the same application, sends a message to it and upon the reception of this message the service replies with a message to the activity.. how do I implement this? Can

How can a remote Service send messages to a bound Activity?

痴心易碎 提交于 2020-01-31 08:51:06
问题 I've read the documentation about Bound Services, where it is shown that you can easily communicate through Messages from an Activity to a remote (i.e. not in the same context) Service but is there any way to send messages from the Service to the bound Activity ? For example, my activity bounds to a running background service of the same application, sends a message to it and upon the reception of this message the service replies with a message to the activity.. how do I implement this? Can

Android connect to Open WiFi programmatically by name - which is Best solution?

别等时光非礼了梦想. 提交于 2020-01-29 17:51:06
问题 I been trying to use two methods to programmatically connect to a open wifi (connective portal) by name. I used op1, but it only works about 80% of times. _____________________________________________________ op1 : public static void connectToWifi(Context context, String networkSSID) { WifiConfiguration conf = new WifiConfiguration(); conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);

Does Binder have to be an inner class?

≡放荡痞女 提交于 2020-01-25 20:25:49
问题 I am reading upon Android Bound service, http://developer.android.com/guide/components/bound-services.html public class LocalService extends Service { // Binder given to clients private final IBinder mBinder = new LocalBinder(); // Random number generator private final Random mGenerator = new Random(); /** * Class used for the client Binder. Because we know this service always * runs in the same process as its clients, we don't need to deal with IPC. */ public class LocalBinder extends Binder

Does Binder have to be an inner class?

百般思念 提交于 2020-01-25 20:25:07
问题 I am reading upon Android Bound service, http://developer.android.com/guide/components/bound-services.html public class LocalService extends Service { // Binder given to clients private final IBinder mBinder = new LocalBinder(); // Random number generator private final Random mGenerator = new Random(); /** * Class used for the client Binder. Because we know this service always * runs in the same process as its clients, we don't need to deal with IPC. */ public class LocalBinder extends Binder

How to find target sim for an incoming call in dual sim android phone?

断了今生、忘了曾经 提交于 2020-01-24 17:24:31
问题 I am creating an android application in which I need to detect the target sim for an incoming call in dual sim phone. The Android API provides the access of only one SIM. I did googling about this but couldn't find the solution, All I found is that we can not detect the target SIM because this is depend upon the device manufactures. Is there any API available to detect the target SIM ? 回答1: in lollipop 22+ public class MessageReceiver extends BroadcastReceiver { @Override public void

How to start the NotificationListenerService on Android

旧城冷巷雨未停 提交于 2020-01-24 09:26:11
问题 I would like to access notifications on a Android phone by using the NotificationListenerService. I checked lots of tutorials but I can't find where they call the service. Should I use bindService or startService on MainActivity? How should the intents look like? Can someone show me the syntax of this? Check out one of the service implementations I am studying: public class NLService extends NotificationListenerService { Context context; @Override public void onCreate() { super.onCreate();

Why so slow Android service restarting with START_STICKY?

浪子不回头ぞ 提交于 2020-01-24 08:50:06
问题 I have a background service, and I am doing all the operations on this service. The service is working with activities at times. But if the application closes, the service restart with START_STICKY ; It works correctly, but sometimes it takes a long time to restart, like more than a minute. @Override public void onCreate() { SocketIOConnect(); super.onCreate(); } @Override public int onStartCommand(Intent intent, int flags, int startId) { return START_STICKY; } How do I reduce the restart