android-broadcastreceiver

Accepting a Call via Bluetooth Headset

天涯浪子 提交于 2019-11-29 18:08:34
问题 i am working on a VoIP-Android-App. I would like to accept and decline Calls via a connnected Bluetooth Headset in an Activity. What I have tried so far: Using a Media Session to receive Media Button clicks. Problem: If we start BluetoothSCO we do not receive any Media Button clicks. If we do not start BluetoothSCO we do receive Media Button clicks but we cannot differentiate long and short button clicks because downtime is always 0, the keycode is always KEYCODE_MEDIA_PLAY and the ACTION

Handle programmatically unregister BroadcastReceiver on process death

我的梦境 提交于 2019-11-29 16:54:09
In my app I register BroadcastReceiver programmatically like that and unregister it in appropriate time with respect to my app's business logic. receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) {...} I want to make sure that when my app's process unexpectedly die (get killed) no memory leak is caused by the receiver and if it does what are my options? (Already check the official doc , this great article and this SO thread ) Onik I want to make sure that when my app's process unexpectedly die (get killed) no memory leak is caused by the

Android 7 intent extras missing

守給你的承諾、 提交于 2019-11-29 14:21:04
问题 Does anyone know if there are any changes to how Android 7.0 (Nougat) handles intent extras compared to Android 6.0 (Lollipop)? Long story short: my app works as intended on all versions from 4.1(16) to 6.0(23) but crashes on android 7.0(24)! The app creates a pending intent with an intent to a custom broadcast receiver which has extras. However, on android 7 none of the extras are present in the intent received by the broadcast receiver. MainActivity.java Intent intent = new Intent(context,

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

喜夏-厌秋 提交于 2019-11-29 08:12:02
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 Internet Connectivity Changes (Which isn't allowed) while the app is in background and if it's important for

I am not able to receive “android.provider.Telephony.SMS_RECEIVED” this broadcast in Android Oreo

梦想与她 提交于 2019-11-28 12:29:39
This is my Menifest file <receiver android:name="com.agribazaar.android.receivers.OTPReceiver" android:exported="true"> <intent-filter> <action android:name="android.provider.Telephony.SMS_RECEIVED" /> </intent-filter> </receiver> This is my Broadcast Receiver class public class OTPReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")){ } } This fixed the issue for me - I wasn't explicitly requesting permission at runtime for android.Manifest.permission.RECEIVE_SMS. In

android broadcast receiver (call and sms received) not working in android nougat

不羁岁月 提交于 2019-11-28 09:52:10
问题 android call and SMS broadcast receiver working perfectly till marshmallow 6.0, but in android nougat , it is not working when app is closed, and when app is in background, then its working fine in android nougat(N). please can anyone help me for this issue. public class CallReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if(intent.getAction().equals("android.intent.action.NEW_OUTGOING_CALL")) { savedNumber = intent.getExtras().getString(

BroadcastReceiver dies with app

夙愿已清 提交于 2019-11-28 02:25:02
If i let the phone sit for a long time like 15 minutes i lose my receiver but i thought it was to persist like a service after being killed for memory. Manifest: <receiver android:name=".WearableReceiver" android:enabled="false"> <intent-filter> <action android:name="com.example.johnbravado.MESSAGE_PROCESSED"/> </intent-filter> </receiver> In Activity to start receiver ComponentName component = new ComponentName(CounterActivity.this, WearableReceiver.class); getPackageManager() .setComponentEnabledSetting(component, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);

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

Fatal Exception: android.app.RemoteServiceException: can't deliver broadcast at android.os.Handler.dispatchMessage

佐手、 提交于 2019-11-28 00:43:01
I am using broadcast messages on my android application (From io.socket I am sending broadcast messages to my Activity page). On some devices Samsung SM-G950F and SM-A520F I got an error " Fatal Exception: android.app.RemoteServiceException: can't deliver broadcast ". I got this error on Fabric crashlytics also I was not able to reproduce this issue. Here is the log I got from Fabric, Fatal Exception: android.app.RemoteServiceException: can't deliver broadcast at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1813) at android.os.Handler.dispatchMessage(Handler.java:102) at

Boot BroadcastReceiver does not work on Xiaomi devices

守給你的承諾、 提交于 2019-11-27 22:28:50
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 permission in Manifest. <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> And