broadcastreceiver

Could AlarmManager.setInexactRepeating not broadcast intents when the device is in sleep mode?

蹲街弑〆低调 提交于 2020-01-15 16:32:38
问题 I have a very simple class that sets and cancels an AlarmManager to broadcast intents: public class MyIntentsAlarm { public void setAlarm(Context context){ AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent("MY_ACTION"); PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0); am.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(),5*60*1000L, pi); } public void cancelAlarm(Context context){ Intent intent = new

Android AlarmManager and BroadcastReceiver running in background Service

a 夏天 提交于 2020-01-15 15:15:47
问题 I'm currently having a problem integrating AlarmManager and BroadcastReceiver. Im my app, I'm running a background service that runs regardless that app is running or not. I think I get this part working fine. The background service keeps an array that changes based on user's location. However, at 8:00am everyday, I want the app to reset the array variable to default. After much looking around online, it seems like the way to do this is via AlarmManager (to initiate the task every 8:00am) and

Android AlarmManager and BroadcastReceiver running in background Service

会有一股神秘感。 提交于 2020-01-15 15:11:54
问题 I'm currently having a problem integrating AlarmManager and BroadcastReceiver. Im my app, I'm running a background service that runs regardless that app is running or not. I think I get this part working fine. The background service keeps an array that changes based on user's location. However, at 8:00am everyday, I want the app to reset the array variable to default. After much looking around online, it seems like the way to do this is via AlarmManager (to initiate the task every 8:00am) and

Android AlarmManager and BroadcastReceiver running in background Service

二次信任 提交于 2020-01-15 15:11:47
问题 I'm currently having a problem integrating AlarmManager and BroadcastReceiver. Im my app, I'm running a background service that runs regardless that app is running or not. I think I get this part working fine. The background service keeps an array that changes based on user's location. However, at 8:00am everyday, I want the app to reset the array variable to default. After much looking around online, it seems like the way to do this is via AlarmManager (to initiate the task every 8:00am) and

Running an android Worker when phone boots doesn't work

泄露秘密 提交于 2020-01-15 10:16:19
问题 I have a worker which functions perfectly. I want to launch it when the phone is booted. I use a broadcast receiver which is supposed to listen to the system booted_completed event, but this broadcast receiver is never called. In my manifest, I added this permission: <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> Here is my broadcast receiver: [BroadcastReceiver(Enabled = true)] [IntentFilter(new[] { Android.Content.Intent.ActionBootCompleted })] public class

Running an android Worker when phone boots doesn't work

为君一笑 提交于 2020-01-15 10:15:10
问题 I have a worker which functions perfectly. I want to launch it when the phone is booted. I use a broadcast receiver which is supposed to listen to the system booted_completed event, but this broadcast receiver is never called. In my manifest, I added this permission: <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> Here is my broadcast receiver: [BroadcastReceiver(Enabled = true)] [IntentFilter(new[] { Android.Content.Intent.ActionBootCompleted })] public class

Android: Getting java.lang.IllegalArgumentException on unregisterReceiver()

心不动则不痛 提交于 2020-01-15 08:11:21
问题 I am having an application where user can register and unregister receiver from Settings to enable and disable service of app. I have taken a toggle button to let user control the app service.I registered a receiver on its on state and unregistered the same on its off state. It works fine when I enable the app service by making toggle button in on state,it successfully registered the receiver and gives me toast. But when I try to click again on toggle button making it in off state,it gives me

How to add home screen shortcut without launching app after installation

旧城冷巷雨未停 提交于 2020-01-15 05:55:27
问题 I am using following code to add shortcut at home screen private void createShortcut() { String appName = getString(R.string.app_name); // Adding shortcut for MainActivity // on Home screen Intent shortcutIntent = new Intent(getApplicationContext(), SplashActivity.class); shortcutIntent.setAction(Intent.ACTION_MAIN); shortcutIntent.addCategory(Intent.CATEGORY_LAUNCHER); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY ); //shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR

How to add home screen shortcut without launching app after installation

可紊 提交于 2020-01-15 05:55:18
问题 I am using following code to add shortcut at home screen private void createShortcut() { String appName = getString(R.string.app_name); // Adding shortcut for MainActivity // on Home screen Intent shortcutIntent = new Intent(getApplicationContext(), SplashActivity.class); shortcutIntent.setAction(Intent.ACTION_MAIN); shortcutIntent.addCategory(Intent.CATEGORY_LAUNCHER); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY ); //shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR

Disconnect incoming call programmatically in android Nougat Api 24

*爱你&永不变心* 提交于 2020-01-15 01:20:40
问题 I'm going to use endCall method of ITelephony.aidl to disconnect all incoming calls programmatically. This is my BroadcastReceiver: public class CallBlocker extends BroadcastReceiver { String number; @Override public void onReceive(Context context, Intent intent) { if (intent.getAction() != null && intent.getAction().equals("android.intent.action.PHONE_STATE")) { disconnectIncomingCall(context); } } private void disconnectIncomingCall(Context context) { ITelephony telephonyService;