broadcastreceiver

Start activity on BroadcastReceiver while receiving SIP Calls

对着背影说爱祢 提交于 2019-12-25 02:35:09
问题 I have my IncomingCallReceiver class from which I want to send my incoming calls to another activity to give user option to Receive or Decline incoming call this is my IncomingReceiver class and clearly out of ideas so If someone might suggest how do I do that. public class IncomingCallReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { SipAudioCall incomingCall = null; try { SipAudioCall.Listener listener = new SipAudioCall.Listener() {

Displaying a message from BroadcastReceiver

久未见 提交于 2019-12-25 02:24:18
问题 I wrote a simple class that extends BroadcastReceiver to handle an incoming call and get the caller's number. Now I want to display that number in a popup window or something similar. I've tried to display an alert dialog or open an activity but my app crashed. Then I read that it's not a good idea to start dialog from a BroadcastReceiver class. I need you to advice me how to correctly display the caller's number on the screen when there's an incoming call. This is my Broadcast Receiver class

Can I register a BroadcastReceiver in code which is raised by a explicit Intent?

烈酒焚心 提交于 2019-12-25 02:20:24
问题 I've learnt that BroadcastReceiver has to be declare in AndroidManifest.xml or registered in code like this: BroadcastReceiver receiver = new MyBroadcastReceiver(); IntentFilter filter = new IntentFilter(); filter.addAction("some_action"); registerReceiver(receiver, filter); But if I want to use a explicit Intent (which does not have IntentFilter s) to start the BroadcastReceiver , how should I register it in code? 回答1: That is not possible. An explicit Intent will only work with a manifest

Broadcast Receiver not working immediately after package installation

六眼飞鱼酱① 提交于 2019-12-25 01:37:19
问题 I am currently working on an app that receives the BOOT_COMPLETED action using a Broadcast Receiver. The receiver is statically registered in the AndroidManifest.xml. It works on the next boot after installation for android 2.2 but not 3.1. With 3.1 I have to start the app once before the broadcast receiver gets the BOOT_COMPLETED action when booting. I suspect that something changed in 3.1 that is causing my receiver to be inactive until the app is started once. Has anyone ever seen this

How to keep and access data in BroadcastReceiver?

喜你入骨 提交于 2019-12-25 00:57:43
问题 If I understand Android manual, BroadcastReceiver is treated as stateless entity, so I should keep a service which will serve as data container (those are my conclusions). As per each request for data access I should execute startService (?) -- I can pass this way data to service, but how to get data back? I mean in recommended way? I could think of passing "out" data, and service on completion would change it, so when startService returns I could check the data I sent in order to retrieve

Android keep BroadcastReceiver while the app is closed

荒凉一梦 提交于 2019-12-25 00:38:02
问题 I use BroadcastReceiver of ACTION_BATTERY_CHANGED to get an event every time the battery is 50%. I can't declare ACTION_BATTERY_CHANGED in manifest, so I declared the BroadcastReceiver in a Service (START_STICKY). But, when I remove the app from recent apps screen the BroadcastReceiver stops getting battery change events. How can I keep it in background? *In many apps that show battery percent in status bar, the percent is updated while the app is closed. How? 回答1: You really cannot do what

android - locale notification, need to dump cache

99封情书 提交于 2019-12-25 00:19:26
问题 We are localizing our app to be able to easily switch between languages. Everything works nicely except for some cached values that are actually in navigation. We have two options: completely restart app on language change - in this case I need a notification and force restart just load new strings into the table - in this case it will require to replace string values and rbuild custom navigation state. IN both cases we need a way to find out when language switches. Is there an intent we can

Unregister BroadcastReceiver which extends a class

喜欢而已 提交于 2019-12-24 19:23:41
问题 I have an class as below: public class FYPSmsReceiverBroadcast extends BroadcastReceiver I need to unregister the receiver as I am getting a force close error AFTER I have existed the application when I receive an SMS message. (indicating something is still listening for the sms but not able to access a particular activity because the app has been closed; the error only seems to happen after 1 text received, a second text seems to produce no force close error) There are a number of somewhat

Android - How to stop showing notification when open application

醉酒当歌 提交于 2019-12-24 19:23:12
问题 I'm new to android development... trying to build application which send notification at specific time daily.First time if I tap on notification it opens application and notification doesn't come again. But after that if I open application it shows notification again.. how to stop showing it again? but show only at particular time? .. MainAcitivty code is: public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate

How to get FCM notification data when app is not in task or killed?

时光总嘲笑我的痴心妄想 提交于 2019-12-24 18:45:48
问题 I need to get data from FCM notifications in android and store them locally, but the problem is I am only able to do that when app is in foreground and then onMessageRecieved is called or when user taps on notification. I want to get notification's data when user gets notification and app is not running, not even in background or foreground. Please suggest something. Thank you in advance. 回答1: You can use BroadcastReceiver public class FirebaseDataReceiver extends BroadcastReceiver { private