broadcastreceiver

Android System date changed event

空扰寡人 提交于 2019-12-28 07:03:45
问题 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="

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

早过忘川 提交于 2019-12-28 06:51:12
问题 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

Can't start activity from BroadcastReceiver on android 10

穿精又带淫゛_ 提交于 2019-12-28 06:39:30
问题 I updated my OS version to android 10 last night, and since then the startActivity function inside the broadcast receiver is doing nothing. This is how I try to start the activity based on the answer of CommonsWare: Intent i = new Intent(context, AlarmNotificationActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { // This is at least android 10... Log.d("Debug", "This is android 10"); // Start the

BroadcastReceiver not receiving download complete action

落爺英雄遲暮 提交于 2019-12-28 04:07:14
问题 I am trying to capture download complete events, but my BroadcastReceiver is not receiving them. Here is the receiver: public class DownloadListenerService extends BroadcastReceiver { @Override public void onReceive(final Context context, Intent intent) { System.out.println("got here"); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences.Editor editor = settings.edit(); String action = intent.getAction(); if (DownloadManager.ACTION_DOWNLOAD

Boot BroadcastReceiver does not work on Xiaomi devices

不问归期 提交于 2019-12-28 04:06:34
问题 I have a following BroadcastReceiver which should run after boot completion. I have tested it on my Xiaomi device (Redmi 1s) , it's not running, while on other devices like Samsung it's running as expected. public class DeviceBootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) { Toast.makeText(context, "I am Running", Toast.LENGTH_SHORT).show(); } } } I have set

Boot BroadcastReceiver does not work on Xiaomi devices

十年热恋 提交于 2019-12-28 04:06:28
问题 I have a following BroadcastReceiver which should run after boot completion. I have tested it on my Xiaomi device (Redmi 1s) , it's not running, while on other devices like Samsung it's running as expected. public class DeviceBootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) { Toast.makeText(context, "I am Running", Toast.LENGTH_SHORT).show(); } } } I have set

Registering and unregistering BroadcastReceiver in a fragment

家住魔仙堡 提交于 2019-12-28 03:29:51
问题 My app has an action bar with 3 fragment tabs. In the second fragment I register and unregister a BroadcastReceiver. I unregister the receiver in onPause and register it in onCreateView and in onResume . getActivity().registerReceiver(this.batteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); and getActivity().unregisterReceiver(batteryInfoReceiver); 1) Is it all right to register the same reciever twice (in onCreateView and onResume)?(is it harmless?) 2) Is it enough to just

android - How to get view from context?

岁酱吖の 提交于 2019-12-28 02:42:26
问题 I want to get the view or findViewById() from Context? Or from intent? I'm trying to reach a specific view in my broadcast receiver and the parameter of onReceive are context and intent. Well, I have a class and within it is my broadcast receiver. Now, I'm trying to separate the broadcast receiver from it, but I need a way so I can still communicate with the views on my class from my separated broadcast receiver class. Thanks. 回答1: For example you can find any textView: TextView textView =

Auto start application after boot completed in Android

試著忘記壹切 提交于 2019-12-28 02:06:11
问题 I want to make an application which has auto start option in its settings. I have made Settings activity in my application which is derived from PreferenceActivity and give CheckBoxPreference for auto start option. If auto start option is enabled my application should start when booting of phone is completed. And if auto start option is disabled then it should not start on boot completed. To achieve this I have implemented derived class of BroadcastReceiver which receives BOOT_COMPLETED

Auto start application after boot completed in Android

隐身守侯 提交于 2019-12-28 02:05:53
问题 I want to make an application which has auto start option in its settings. I have made Settings activity in my application which is derived from PreferenceActivity and give CheckBoxPreference for auto start option. If auto start option is enabled my application should start when booting of phone is completed. And if auto start option is disabled then it should not start on boot completed. To achieve this I have implemented derived class of BroadcastReceiver which receives BOOT_COMPLETED