broadcastreceiver

LocationManager.PROVIDERS_CHANGED_ACTION will not work on API 26 and higher

混江龙づ霸主 提交于 2019-11-28 02:43:21
问题 I am using following code to get location on/off event. <receiver android:name=".receivers.GpsReceiver" android:enabled="true"> <intent-filter> <action android:name="android.location.PROVIDERS_CHANGED" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </receiver> I am developing geofence based app. Based on Re-register geofences only when required we have to re register the geofences after the app has received a GEOFENCE_NOT_AVAILABLE alert. This typically

Android System date changed event

谁说胖子不能爱 提交于 2019-11-28 02:13:36
I know this question has been asked many times but i am unable to find the right direction. I have registered BroadcastReceiver which I want to trigger when the Android System Date is changed automatically but its not firing. I have used the following approaches: 1 IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_TIME_CHANGED); registerReceiver(new DateTimeChangeReceiver (), intentFilter); 2-> AndroidManifest.xml <receiver android:name=".DateTimeChangeReceiver "> <intent_filter> <action android:name="android.intent.action.DATE_CHANGED"/> </intent_filter> <

Widget sending multiple types of intents

白昼怎懂夜的黑 提交于 2019-11-28 02:11:51
问题 I am building a widget that has multiple buttons, each one sending off its own intent to a broadcast receiver. The broadcast receiver is suppose to display a Toast message based on which button was pushed. The code currently looks like this: public class WidgetProvider extends AppWidgetProvider { @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds){ ComponentName thisWidget = new ComponentName(context, WidgetProvider.class); int[] allWidgetIds

How to register broadcast receiver?

怎甘沉沦 提交于 2019-11-28 01:54:49
问题 Here is my source code and it keeps force closing everytime I run it... public class MainActivity extends Activity { private static String content; private static String phone; private String number; private String message; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); registerReceiver(new BroadcastReceiver(){ @Override public void onReceive(Context context,

Broadcast-receiver which always receives broadcast (even in background) for API Level +26

安稳与你 提交于 2019-11-28 01:46:43
问题 I'm posing this as Q&A style because I found this idea working. And it's a fix to the hard problem to crack for beginners with Android. Google has deprecated registering Broadcast Receiver into manifest like this below from API Level 26+ ( Except Some ) <receiver android:name=".MyBroadcastReceiver" android:exported="true"> <intent-filter> <action android:name="android.net.wifi.STATE_CHANGE" /> </intent-filter> </receiver> But, If one wants to receive particular device state changes like

How to raise an alert dialog from BroadcastReceiver class?

旧巷老猫 提交于 2019-11-28 01:26:24
问题 I have used a timer method in an Activity class. In that method I have an intent from Activity class to a BroadcastReceiver class. This BroadcastReceiver class will call on every 15 minutes at background by using AlarmManager . When I call the BroadcastReceiver class I would like to raise an AlertDialog . public void timerMethod(){ Intent intent = new Intent(Activity.this, BroadcastReceiverClass.class ); PendingIntent sender = PendingIntent.getBroadcast( QualityCallActivity.this,0, intent, 0

Android capturing volume up/down key presses in broadcast receiver?

别来无恙 提交于 2019-11-28 01:24:46
I'm trying to make an application where the user can override the default behaviour of the volume up/down buttons (as well as the screen on/off button - is this possible?). Anyways, using some code along the lines of the following I can do this: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { super.onKeyUp(keyCode, event); if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP)) { //this is where I can do my stuff return true; //because I handled the event } return false; //otherwise the system can handle it } But I would like it to be possible even when the application is not open,

Is android.permission.RECEIVE_BOOT_COMPLETED not required?

南楼画角 提交于 2019-11-28 01:18:40
问题 Does anyone know why my application still receives the ACTION_BOOT_COMPLETED broadcast even when my app doesn't have the permission android.permission.RECEIVE_BOOT_COMPLETED in the manifest file? I thought it was required but a few tutorials I used also didn't have it. A few did. I use my phone running CyanogenMod for testing but I doubt that matters. LogCat shows my "Notified of boot" log upon each boot. See below for code used. AndroidManifest.xml <receiver android:name="AlarmReceiver">

BroadcastReceiver and AlarmManager Android

旧城冷巷雨未停 提交于 2019-11-28 01:11:17
问题 I am trying to use an alarm manager with BroadcastReceiver. I try to use the example given in Tutorial: System Services and BroadcastReceiver . but when I run the example after the end of the time the toast doesn't show up. the code is below: My main Activity: public class AlarmActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_alarm); }

Getting multiple broadcasts from intents?

我与影子孤独终老i 提交于 2019-11-28 01:02:29
问题 http://mobiforge.com/developing/story/sms-messaging-android I used the example code in the above link my own application for sending an SMS, but I run into a problem when checking the sent status of my message. What happens is, the toast message will pop up for every message I have attempted to send. So basically, let's say I've already sent 3 messages. When I go to send my 4th message, the toast message will pop up 4 times. It seems that perhaps the BroadcastReceiver is receiving the same