android-broadcast

How to perfectly sync clock app widget with system clock in Android?

一世执手 提交于 2021-02-08 10:40:14
问题 I made a digital clock widget which is using AlarmManager to update the time every 60 seconds. @Override public void onEnabled(Context context) { super.onEnabled(context); Log.d("onEnabled","Widget Provider enabled. Starting timer to update widget every minute"); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.setRepeating(AlarmManager.RTC, System.currentTimeMillis(), 60000, createClockTickIntent(context)); } The problem is, polling the

Broadcast receiver called 2 times when turning off GPS?

ぃ、小莉子 提交于 2021-01-27 05:25:21
问题 Manifest: <receiver android:name=".GpsLocationReceiver"> <intent-filter> <action android:name="android.location.PROVIDERS_CHANGED" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </receiver> BroadcastReceiver: public class GpsLocationReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "onReceive..."); if(intent.getAction().matches("android.location.PROVIDERS_CHANGED")) { Log.d(TAG, "GPS provider

BroadcastReceiver not firing on notification action click

被刻印的时光 ゝ 提交于 2020-06-16 05:06:48
问题 I am trying to create a simple notification with a button (action) defined to it. I have managed to display it properly and create a PendingIntent for my action. I have also created a BroadcastReceiver which is supposed to be called when my action is clicked. But it's onReceive() method does not get called. I have no idea why. I also registered BroadcastReceiver in AndroidManifest.xml MainActivity.java public class MainActivity extends AppCompatActivity { @Override protected void onCreate

Android Broadcast Receiver is not working in background

烂漫一生 提交于 2020-05-14 07:42:13
问题 I have 2 Android mobile cellphones with different Android versions. The first cellphone is running Kitkat and the second one Nougat. I'm currently using the following code. After 5 or 7 hours the android application is not detecting events anymore. Can someone please help me out? package com.doct.patients.Broadcast; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.widget.Toast; public class smsReceiver extends

Android Broadcast Receiver is not working in background

心不动则不痛 提交于 2020-05-14 07:40:08
问题 I have 2 Android mobile cellphones with different Android versions. The first cellphone is running Kitkat and the second one Nougat. I'm currently using the following code. After 5 or 7 hours the android application is not detecting events anymore. Can someone please help me out? package com.doct.patients.Broadcast; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.widget.Toast; public class smsReceiver extends

How to find target sim for an incoming call in dual sim android phone?

断了今生、忘了曾经 提交于 2020-01-24 17:24:31
问题 I am creating an android application in which I need to detect the target sim for an incoming call in dual sim phone. The Android API provides the access of only one SIM. I did googling about this but couldn't find the solution, All I found is that we can not detect the target SIM because this is depend upon the device manufactures. Is there any API available to detect the target SIM ? 回答1: in lollipop 22+ public class MessageReceiver extends BroadcastReceiver { @Override public void

How to fix the Android error “Background execution not allowed: receiving Intent {…}”

笑着哭i 提交于 2020-01-22 02:52:05
问题 So I'm programming an Android app that uses Bluetooth discovery of devices. Here is the code I use to start discovery. try { myBluetoothAdapter.startDiscovery(); Log.d("Bluetooth Started successfully","yes"); } catch (Error e) { Log.d("FAILED","Ya failed mate"); e.printStackTrace(); } I then register a BroadcastReceiver to watch for when devices are found. Here is my code for that IntentFilter intentFilter = new IntentFilter(BluetoothDevice.ACTION_FOUND); final ArrayList<String>

Android - Custom action in Broadcast Intent

此生再无相见时 提交于 2020-01-16 06:07:34
问题 I am trying to allow user to post comment when he is offline such that whenever wifi/internet is turned on his comment will be posted.Fot that I am using BroadCastReceiver.But the issue i am having is that it is never going inside if (intent.getAction().equals("commentpost")) if i try switching on wifi after clicking on postcomment.However it does go inside if (wifi.isAvailable() || mobile.isAvailable()) whenever i switch on wifi.I failed to understand where i am going wrong.My log shows

Android - Custom action in Broadcast Intent

。_饼干妹妹 提交于 2020-01-16 06:06:16
问题 I am trying to allow user to post comment when he is offline such that whenever wifi/internet is turned on his comment will be posted.Fot that I am using BroadCastReceiver.But the issue i am having is that it is never going inside if (intent.getAction().equals("commentpost")) if i try switching on wifi after clicking on postcomment.However it does go inside if (wifi.isAvailable() || mobile.isAvailable()) whenever i switch on wifi.I failed to understand where i am going wrong.My log shows