broadcastreceiver

SMS Broadcast Receiver not working

前提是你 提交于 2019-12-02 03:06:40
Alright, I have tried every solution on Stack and nothing works.My current method registers the "SmsListener" receiver from the MainActivity. All I'm trying to do is initialize the onReceive method. There are no errors; It simply isn't picking up a broadcast. What am I doing wrong? Pasting the applicable code here. Anything else that may be needed please just ask. Update: Here is a similar unresolved issue Listen Android incoming SMS when Google Hangout or other app receives it I am testing under Android 6.0.1. Target Sdk version is 22. Min Sdk is 19. It's worth noting that I just tested my

Android - Stop broadcast receiver being killed with service

六眼飞鱼酱① 提交于 2019-12-02 03:02:43
I have built an application which implements a number of broadcast receivers and registers them within a service based on user settings. The service is bound to an activity which calls some of its methods. When a broadcast receiver is called it starts the service (or calls onstart of the service if it is already running) and passes it a string telling the service what to do. My problem is when the activity is destroyed (back button) the service is also destroyed which in turn kills the broadcast receivers. I know I can register the receivers in the manifest which would mean doing a check when

Android Broadcast Receiver showing a dialog?

▼魔方 西西 提交于 2019-12-02 02:48:08
问题 I've got an app that responds to an Alert - and I really need to show an alert with a password entry before going on to the next screen; the trouble is I don't seem to be able to show a dialog from a broadcast receiver -- so how can I show a dialog password entry upon receiving an alert? 回答1: Create an activity, using Theme.Dialog , and call startActivity() to open it. While you cannot use a "real" Dialog , you can create a UI that looks like a Dialog . Bear in mind that popping up an

How to Keep the CPU of android phone always awake?

二次信任 提交于 2019-12-02 02:42:24
I have been stuck on it for days. I need to execute a function every minute. This function is making a POST call from the App to the Server and is transferring the location of the user per minute. The location coordinates are transferred for few hours, however, after few hours the transfer of location coordinates to the Server stops on its own. I am making use of WakefulBroadcastReceiver and IntentService to make sure that the CPU stays awake. I am also making use of Alarm to make sure that the function is executed every minute. This is how my WakefulBroadcastReceiver looks like: public class

Can an ACTION_USER_PRESENT BroadcastReceiver not be registered in the manifest?

久未见 提交于 2019-12-02 02:02:33
I see that multiple broadcasts ( ACTION_TIME_TICK , for example) cannot be registered in the manifest, the must be explicitly registered via Context.registerReceiver() . I am having trouble with the ACTION_USER_PRESENT broadcast intent. Specifically, I test on the emulator and my application keeps force closing with the error: 08-30 09:44:23.397: ERROR/AndroidRuntime(290): java.lang.RuntimeException: Unable to start receiver me.turnerha.RegisterListeners: java.lang.IllegalArgumentException: Receiver not registered: me.turnerha.RegisterListeners@43d05690 This is caused by 08-30 09:44:23.397:

alarm manager not working while updating interval time

老子叫甜甜 提交于 2019-12-02 01:44:46
after reading all the QA i didnt get any proper solution. I have 2 problems 1. Alarm fires twice even if i register my receiver only in manifest.(not by code) 2. when i update interval time of alarm it gets fires randomly here is my method for set alarm public void AlarmCall(int min) { Intent intent = new Intent(context, AlarmReceiver.class); PendingIntent pintent = PendingIntent.getBroadcast(context,0 , intent, 0); alarm = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); cancelAlarm(alarm,pintent); if(Build.VERSION.SDK_INT<18) { alarm.set(AlarmManager.RTC_WAKEUP, 1000 * 60 * min

Broadcast receiver for GPS state?

邮差的信 提交于 2019-12-02 01:34:08
Is there a way to be notified when the GPS is switched on/off? I noticed that when the device is switched off an then on again, getLastKnownLocation(provider) is null. So I want to save the location when the GPS is switched off to a database. Register a BroadcastReceiver to listen for the LocationManager's PROVIDERS_CHANGED_ACTION Intent. This will be broadcast when the GPS provider (and other providers) is enabled / disabled. 来源: https://stackoverflow.com/questions/11446428/broadcast-receiver-for-gps-state

Broadcast receiver is triggered automatically on start

隐身守侯 提交于 2019-12-02 01:09:14
I have a registered BroadcastReceiver in my main activity. Activity sends a sticky in one of the tabs to trigger the broadcast receiver ( TabActivity application). Everything works fine, but when I restart the app the sticky is sent automatically (not triggered by user) and view is opened. My question is: how is that possible? Did I misunderstand something? And how can I fix that? MainActivity: OnCreate: registerReceiver(openOutgoingCall, new IntentFilter("OPENOUTGOINGCALL")); BroadcastReceiver: private BroadcastReceiver openOutgoingCall = new BroadcastReceiver() { @Override public void

Android activity not getting broadcast from local service

此生再无相见时 提交于 2019-12-02 00:52:10
From the examples this looked straightforward. Maybe you can show me what I did wrong. I can't get an activity to receive a broadcast sent from a local service. I have Activity1 that start Service1: startService(new Intent(Activity1.this, Service1.class)); Activity1 then starts Activity2: startActivity(new Intent(Activity1.this, Activity2.class)); Service1, a local service, listens for downloads: protected final BroadcastReceiver service2DownloadBroadcastReceiver = new BroadcastReceiver() { public void onReceive(final Context context, final Intent intent) { ... broadcastDownloadFinished(Uri

How to detect incoming call with the help of Broadcast Receiver?

断了今生、忘了曾经 提交于 2019-12-01 23:32:32
I'm trying to recognize incoming calls in thru a broadcast receiver. I'm UNABLE to do so! Infact, I'm unable to 'trigger' the broadcast! Here's my code: activate.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(getApplicationContext(),"Clicked",1).show(); final String BROADCAST_ACTION_NAME = ".BroadcastMM"; Intent intent = new Intent(); intent.setAction(BROADCAST_ACTION_NAME); sendBroadcast(intent); } } I dunno if this 'sendBroadcast' is ever triggered! In my Broadcast Receiver file: public void onReceive(Context context, Intent intent) { if