broadcastreceiver

Any way to receive a broadcast before the network goes down

别来无恙 提交于 2020-02-02 19:59:09
问题 I already have a few receivers running, including one for reboot and entering flight mode. However I'm not always getting the Intent in time for me to do what I need to do, send a quick message to an external server. Even setting the intent filter to priority 1000 doesn't guarantee that I get to transmit before it is too late, though it does help. As stated, it is not that I do not receive my broadcasts, I just get them too late, after the network is already down. Any pointers to where I may

startActivity() from BroadcastReceiver

余生颓废 提交于 2020-01-26 09:47:07
问题 I am trying to autostart my nightclock application on charging using the following BroadcastReceiver implemented in the onPause() method: BroadcastReceiver test = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { unregisterReceiver(this); Intent i = new Intent(context, NightClock.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); } }; registerReceiver(test, new IntentFilter(Intent.ACTION_POWER_CONNECTED)); The onReceive()

startActivity() from BroadcastReceiver

China☆狼群 提交于 2020-01-26 09:45:08
问题 I am trying to autostart my nightclock application on charging using the following BroadcastReceiver implemented in the onPause() method: BroadcastReceiver test = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { unregisterReceiver(this); Intent i = new Intent(context, NightClock.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); } }; registerReceiver(test, new IntentFilter(Intent.ACTION_POWER_CONNECTED)); The onReceive()

Is it possible that two BroadcastReceiver from two apps, based on the same broadcast intent action, somehow “collide”?

故事扮演 提交于 2020-01-26 04:15:30
问题 I have a BroadcastReceiver inside a service: public class NotificationClickService extends Service { private static final String DEBUG_TAG = "NotificationClickService"; @Override public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } @Override public void onCreate() { registerReceiver(NotificationClickReceiver, new IntentFilter(DownloadManager.ACTION_NOTIFICATION_CLICKED)); } @Override public void onDestroy() { unregisterReceiver(NotificationClickReceiver); }

Start Service from BroadcastReceiver phoneListener

主宰稳场 提交于 2020-01-25 20:37:12
问题 I want to stop the the running service when the phone is ringing and I want to restart the service when the call is answered or just after ringing. I always get an java.lang.NullPointerException if the phone call ends. In the CALL_STATE_RINGING the alarmManager cancels and the service stops without any error. Starting the Service again, does not work. I get all the time following NullPointerException. 03-18 19:08:30.280 15795-15795/de.app.test E/AndroidRuntime﹕ FATAL EXCEPTION: main Process:

Android broadcast receiver not working when trying to receive bootcomplete or screen off

戏子无情 提交于 2020-01-25 20:31:09
问题 So I am trying to develop a custom lockscreen but my broadcastreceiver won't fire my manifest : <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.alexander.fuchs.lockscreen" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" >

Weird behavior when trying to detect when Wifi network connected android

耗尽温柔 提交于 2020-01-25 11:01:07
问题 I am currently trying to do a relatively simple task in Android. I want to detect when a wireless network is fully connected. At this moment I do not care whether there is internet connection, I just want to know the exact moment when my device is considered connected to network. I will try to describe what I did, and how miserably had I failed. Bare in mind that I have tried official recommendations as well as some answers here but to no avail. Activity registers receiver: IntentFilter

USB Permissions not received by Broadcast receiver

百般思念 提交于 2020-01-25 10:15:11
问题 Good evening community, I am reaching with the hopes of being educated about the following problem. My intention with this code is to be able to handle USB permission intents in a receiver registered in a manifest file. The receiver gets USB Attached and detached actions, but not USB permissions when the user either accepts or declines the prompt. Here is the code for the manifest, receiver and an activity to send the permissions request to the USB manager. And Finally, my target SDK is 28.

Can't start activity from BroadcastReceiver on android 10

陌路散爱 提交于 2020-01-25 08:53:10
问题 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

Running a service on Outgoing Calls in Oreo

余生颓废 提交于 2020-01-24 14:04:03
问题 I'm developing an app which needs to run some code (Open Activity) whenever an call to specific number is performed. In API 24 and lower it's fine, I register an implicit receiver in Manifest file and start my service in the specified class which extended BroadcastReceiver. In API 26 however you cannot register android.provider.Telephony.OUTGOING_CALL in a receiver since it won't work. From Android documentation: Note: If your app targets API level 26 or higher, you cannot use the manifest to