broadcastreceiver

AlarmManager: how to schedule a daily alarm and deal with time changes

纵然是瞬间 提交于 2019-12-03 06:03:30
I need to set up an alarm daily at a given hour. I'm programming the alarm using AlarmManager.RTC_WAKEUP , so it uses the system time as reference. I'm setting the alarm to first execute at the desired hour, then to repeat daily: alarmManager.setRepeating( AlarmManager.RTC_WAKEUP, getTimestampToday("12:00"), AlarmManager.INTERVAL_DAY, pendingIntent ); The getTimestampToday method returns a long timestamp for today at the desired hour. It does so by obtaining the local date for today, then setting the desired hour, finally converting it back to a timestamp (which is UTC based). The problem here

What is more efficient Broadcast Receiver or Handler?

岁酱吖の 提交于 2019-12-03 05:07:01
问题 I know that onReceive() of the Broadcast receiver and handleMessage() of Handler run on the same UI thread. Suppose I want to communicate between two services, within the same app (process) . I can extend a broadcast receiver class and register an event OR a Handler and then pass its instance to the other service to be used for sendMessage() calls. In both the cases I would need to add some new switch case. But which approach is more efficient ? Lets assume that the code is thread safe (no UI

Broadcast receiver not receiving intent

白昼怎懂夜的黑 提交于 2019-12-03 03:59:04
问题 I have two apps that I have complete control over. Both are signed with the same cert and both use the exact same intent filter. One sends the broadcast from a fragment, the other is suppose to receive it and do something. This however is not working: Strings.FILTER_INIT_REGISTER = "com.app.FILTER_INIT_REGISTER" Intent intent = new Intent(Strings.FILTER_INIT_REGISTER); getActivity().sendBroadcast(intent); I have registered the receiver in the Manifest app tag for the app containing the

List of Android task killers

て烟熏妆下的殇ゞ 提交于 2019-12-03 03:58:46
I am trying to do a list of Android task killers that are installed by default on the operating system. The problem is that Android is modified by the phone's manufacturer and it is hard to keep up with what everyone is doing. So far I have found this: Smart manager - On Samsung phones. Could not call alarm manager but you can avoid this if your package name contains "alarm" or "alert" Doze - On Android 6. should not interrupt the app but it may delay alarm manager or network processes(especially if your app is not active and your phone is not charging). Xiaomi , AutoStart . If AutoStart is

RTC_WAKEUP is not working

蹲街弑〆低调 提交于 2019-12-03 03:54:47
Currently i am working on a Broadcast Receiver application, in which i am making an Alarm which should display a message after we enter the seconds. I used RTC_WAKEUP, which means it should display the message when the device is on and it is supposed to turn on the device and then display the message when the device is off. MY PROBLEM IS THAT IT RTC_WAKEUP DOESN'T ON MY DEVICE but it is working properly when device is on. i am pasting the code of my application. In my application there are two classes. MainActivity public class MainActivity extends Activity { @Override public void onCreate

Android - How to detect outgoing call is answered or received?

风流意气都作罢 提交于 2019-12-03 03:48:26
Is there any way to detect outgoing call is successfully received or answered ? I am using Intent.ACTION_CALL for dialing a call and PhoneCallListener to find the state of a call when outgoing call answered but I couldn't have been achieving this. Is this possible in android ? Mohammad Qandeel After deeply working on this issue, I reached this conclusion: PhoneStateListener won't work for outgoing calls, it calls OFFHOOK instead of RINGING and OFFHOOK is never called on ANSWER. Using NotificationListenerService , you can listen to posted notifications related to outgoing calls. You can do

LocalBroadcastManager vs Context.registerReceiver(), Context.sendBroadcast(Intent), and Context.unregisterReceiver() are they same?

て烟熏妆下的殇ゞ 提交于 2019-12-03 03:06:24
问题 I was using Context.registerReceiver(), Context.sendBroadcast(Intent) , and Context.unregisterReceiver() but when I saw the class LocalBroadcastManager , it has registerReceiver(), sendBroadcast(Intent) , and unregisterReceiver() like in Context . I'm confused. When should I use the LocalBroadcastManager ? are they same in Context ? Regards, Thanks... 回答1: LocalBroadcastManager is as its name says, an implementation of the broadcast methods that are only available to your app. This has some

TaskStackBuilder#startActivities() NullPointerException

放肆的年华 提交于 2019-12-03 02:59:29
I have a crash that keeps occurring on 4.4.2 and 4.4.3 devices (although I'm not sure this is an API issue), where in some ParsePushBroadcastReceiver the following code causes a NullPointerException somewhere deep inside the startActivities call. Intent intent = new Intent(context, SomeActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); TaskStackBuilder.create(context) .addParentStack(SomeActivity.class) .addNextIntent(intent) .startActivities(); I have tried testing to see whether the context was null, however, the Intent instantiation would've caught that. It might also be worth

How to check VPN connection status on Android ICS

江枫思渺然 提交于 2019-12-03 02:55:43
I'm trying to register receiver, that will check VPN status. I have tried this: Get VPN Connection status on Android but looks like it no longer works on ICS. I have checked android source code for some clue, but with no luck, only noticed that in ISC there is nothing like: vpn.connectivity and connection_state - it use to be in android 2.3. Also tried using android.net.conn.CONNECTIVITY_CHANGE as my IntentFilter , but it doesn't react on VPN connection at all (of course I have added permission android.permission.ACCESS_NETWORK_STATE ). I thought that it is simple thing to do, but I already

How to debug BOOT_COMPLETE broadcast receiver's “Force Close” crashes?

自作多情 提交于 2019-12-03 02:27:05
问题 Since the phone restarts and thus gets disconnected from the Eclipse debugger/LogCat while it's booting up, how do I see where my boot complete broadcast receiver is crashing? I am performing some actions in the onReceive() of my public class BootCompleteReceiver extends BroadcastReceiver { ... } This is crashing and popping up a force close dialog when the phone boots. How do I debug this and see where the problem is? The question holds true for debugging any BOOT_COMPLETE broadcast