broadcastreceiver

Access to application class in Broadcast Receiver

眉间皱痕 提交于 2019-11-29 18:50:14
问题 I want to check internet connection in Broadcast Receiver; And set result (A boolean flag) to a global variable, to use it on whole application, in if conditions; That if internet is disconnected, set a status imageview in main activity, to red image, and if connected, set it to green. I followed this topic. But there is no getApplication() in Broadcast Receiver; And iI should use getApplicationContext() instead. On another side, this topic: when writing code in a broadcast receiver, which is

How to include a BroadcastReceiver in a different project Xamarin project?

那年仲夏 提交于 2019-11-29 18:16:36
I'm writing a cross-platform solution in Xamarin, and am about to add a mother project for 3rd-partyu integration (e.g., other Android-parties that want to integrate with my app using intents on Android only). But I'd like to keep my cross-platform setup that I have now "clean" and simply add a new Android class library with the 3rd-party integration code. However, I cannot seem to get my BroadcastReceiver in my 3rd-party integration project to be included in my "main" android app project. I've added a reference to the 3rd-party integration project, but that's obviously not sufficient... I

Best way to use TriggerEventListener in the background?

天涯浪子 提交于 2019-11-29 17:35:48
I'm looking to make an application that runs in the background, logging location data without the user actually having to have the application in the foreground but at the same time doesn't use too much battery. I originally thought of setting a BroadcastReceiver for BOOT_COMPLETED and run a service which uses a Significant Motion sensor to log location data whenever the it fired off, but ever since Oreo, there are alot of limitations on background services. What is the best way to do this? You can use JobService it's efficient in terms of battery and modern way to perform the task in the

BroadcastReceiver Doesnt work if I close Recent Apps

回眸只為那壹抹淺笑 提交于 2019-11-29 17:35:00
I am Trying to make an app which app will be called if a particular thing triggered. In my App this thing is sms.. When a new Sms Receiving I Read its contents and i Look for a Specific Content If it presents an alarm will goes on. If the App is opened its just working fine. The receiver triggers good... but when i clear recent apps receiver not triggering. I searched a lot here.. and Most of us saying that when an app in STOPPED_STATE it wont receive any notification that the particular thing happened. I have an android device Hauwei and android version 4.4.4 and when i clear my recent

Android detect Bluetooth disconnect immediately Max 2 seconds

旧城冷巷雨未停 提交于 2019-11-29 16:59:32
问题 I'm looking for a way to detect the disconnection of a Bluetooth device immediately after it has happened (2 second max), typically in a "device too far" scenario or Device battery is dead. Currently I can detect it with a BroadcastReceiver by getting a BluetoothDevice.ACTION_ACL_DISCONNECTED , but it takes about 16 to 20 seconds to fire. Is there any way to get notified in 2 seconds Max. I used BroadcatReceiver but it is not fast enough to get alert in 2 seconds Max, so is there any other

Receiver stopped receiving in Oreo

女生的网名这么多〃 提交于 2019-11-29 16:10:40
问题 I understand services and such are being clamped down on, so my receiver has stopped working in Android Oreo. I have this code starting the service - Intent intent = new Intent(this, MyService.class); intent.putExtra("Time", locationUpdatesTime); intent.putExtra("Dist", locationUpdatesDistance); startService(intent); I have this in my service - Intent intent = new Intent(); intent.setAction("com.androidandyuk.laptimerbuddy"); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); intent

Scheduled Notifications Triggers Every Time I Open App

拥有回忆 提交于 2019-11-29 16:09:56
I am building an app which triggers a notification at 11:30 IST..I have Tested It Its Working But After 11:30 Whenever i open my app it issues a notification... i don't know why i think it should be some error in condition in time checking... i want notification to be triggered on time only once in a day...and then the next day...:) please resolve this thanks in advance **MainActivity.java** @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); spinner = (ProgressBar)findViewById(R.id.progressBar); spinner

Why won't this broadcast receiver work in Lollipop?

只谈情不闲聊 提交于 2019-11-29 15:48:38
I have this broadcast receiver declared in the Manifest: <receiver android:name="classes.VoiceLaunchReceiver" > <intent-filter> <action android:name="android.intent.action.USER_PRESENT" /> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver> It does its thing whenever the user unblock and turns on the screen. It works perfectly in Jellybean 4.3 and lower. Why won't it work in Lollipop? (I already know that the systems send that intent, what I want is to detect it with my receiver) Ok, I solved the issue by adding two things: a permission, and a category

Android Wifi Scan - BroadcastReceiver for SCAN_RESULTS_AVAILABLE_ACTION not getting called

萝らか妹 提交于 2019-11-29 15:20:59
问题 Here is my code: public class FloatWifiManager implements IWifiManager { private WifiManager wifiManager; private BroadcastReceiver wifiScanReceiver; public FloatWifiManager(Context context) { ... wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); // Registering Wifi Receiver wifiScanReceiver = new BroadcastReceiver() { @Override public void onReceive(Context c, Intent intent) { if (intent.getAction().equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)) { // not getting

Android - getting “can't deliver broadcast” error on dynamically registered broadcast receiver

情到浓时终转凉″ 提交于 2019-11-29 15:18:13
I'm trying to perform a relatively simple task: I have a fragment that starts a service to pull some JSON from a remote server. I then want to pass that JSON back to the original calling fragment using a broadcast, with the BroadcastReceiver defined as an anonymous class in the fragment. However, whenever I try to do this, I keep getting the following error: E/AndroidRuntime: FATAL EXCEPTION: main Process: com.roundarch.codetest, PID: 21974 android.app.RemoteServiceException: can't deliver broadcast at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631) at android.os.Handler