Broadcast Receiver - Part 3, Listening to custom intent broadcasts

Broadcast Receiver - Part 3, Listening to custom intent broadcasts

Codetutor

7 лет назад

32,135 Просмотров

In this video we discuss how to broadcast an intent so that a Broadcast Receiver can listen to it and respond to it. The video also demonstrates the use of exported attribute to secure the broadcast Receiver and also how to use LocalBroadcastManager to restrict the intent broadcast propagation outside the app.

Follow me on Twitter: https://twitter.com/anilvdeshpande

Source Code GitHub links:

SampleBRTutorial: https://github.com/AnilDeshpande/SampleBRTutorialCode/tree/custom-intent-broadcast
LocalBRTester: https://github.com/AnilDeshpande/LocalBRTester

Тэги:

#Anil_Deshpande #Codetutor #Anil_V_Deshpande #LocalBrodcastManager #Local_Broadcast_Manager #intent_broadcast #custom_intent_broadcast #Listening_to_custom_intent_broadcast #Triggeting_Brodcast_Receiver #BroadcastReceiver #Broadcast_Receiver
Ссылки и html тэги не поддерживаются


Комментарии:

Shubhpreet Rana
Shubhpreet Rana - 03.07.2021 21:34

For second application we need to setPackage("ReceiverApp PAckage NAme ")

Ответить
Aman Aggarwal
Aman Aggarwal - 14.09.2020 22:29

kamal ho sir kha chup k baithe the hum angrezo ki video dekhte reh gye aur app yha bdiya content de rhe ho woh dekha nhi tha aaj tak.

Ответить
Bhuvanendra Pandian
Bhuvanendra Pandian - 01.09.2020 19:11

Will broadcast receiver work when we kill the app?

Ответить
ramesh vadapalli ramesh
ramesh vadapalli ramesh - 18.07.2020 13:19

can we send broadcast receiver from one activity to another activity in same app?

Ответить
random postings
random postings - 14.04.2020 17:52

does second app have to be in foreground to get triggered by latter one

Ответить
Safwen chaieb
Safwen chaieb - 21.03.2020 14:57

Thank you sir <3 ,I have a problem confused me so much : the broadcast receiver listen to BOOT_COMPLETE action in some devices (huawei p9 lite , some emulators) but in some devices (samsung A2Core , some emulators) broadcast receiver can't receive to BOOT_COMPLETE , is there any tricky solution ? and thank you !

Ответить
Daniel Ravichandran
Daniel Ravichandran - 10.01.2020 14:08

Great video Sir! I am using Broadcastreceiver in a college project of mine and got stuck. Hopefully you can help.

The project is a bluetooth project. The bluetooth part is working perfectly. I am receiving the data in this format "3.6666&8.9999". These are latitude and longitude values I need to plot in a map. But I am unable to use the values outside the Broadcastreceiver. Please do help. I have attached the code below.

BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {

String text = intent.getStringExtra("theMessage"); // The "3.6666&8.9999" is inside this

Log.i("text sample", text);

String coordinates[] = text.split("&");

btlatitude = Double.parseDouble(coordinates[1]); //3.6666
btlongitude = Double.parseDouble(coordinates[0]); 8.9999

incomingMessages.setText(text);

Log.i("text sample lat", String.valueOf(btlatitude));
Log.i("text sample long", String.valueOf(btlongitude));

}
};

Ответить
Akshay Jain
Akshay Jain - 23.12.2019 09:56

first all your videos are awesome , i have a question that how and where did you mentioned about the second app in your first app that it will receive the msg , like when i send a msg to someone i have to mention or write a phone number (like an address to the other app user )... where did you do that in your app that it could know that which app will receiver the msg ... thank you ..
and again your videos are awesome ....

Ответить
Gagan Singh
Gagan Singh - 15.07.2019 12:55

Sir, this is working but when I remove Receiver app from "recent apps" and fire broadcast from another app then that receiver app doesn't recieve that broadcast, however i have set exported attribute to true and declared receiver both in manifest and java file...please help.

Ответить
Seif Kharrachi
Seif Kharrachi - 03.07.2019 17:43

i like you when you say
FOR THAT

Ответить
M S H Sajal
M S H Sajal - 21.04.2019 09:13

I am using android PIE. I saw the quick fix update. Now I can trigger BR locally but having problem with remote access. BR is not responding while I want to access from remote app.

Ответить
Rahul Nag
Rahul Nag - 22.03.2019 04:55

Hi sir,


can you please tell some real time example of using localBrodcastManager
or some existing app example which are using this.


Thanks,
Rahul

Ответить
Vijaynath
Vijaynath - 24.01.2019 18:43

Thank u gurudevvvvvvv

Ответить
Oumaima KABOURI
Oumaima KABOURI - 26.12.2018 12:53

helped in my preparation, Excellent explanations.thanks

Ответить
Sunny Sinha
Sunny Sinha - 26.09.2018 15:57

helped in my project

Ответить
52Tele
52Tele - 16.09.2018 19:35

Hello Sir,
Is there a way to listen to any inter-app communication between two or more Android applications?

Ответить
Pankaj Tolwani
Pankaj Tolwani - 20.07.2018 10:43

hi sir,
I have used your code but not getting any message when i press button(broadcast is sent but not received) .. what can be the possible mistake im doing?????

Ответить
Tech Item
Tech Item - 17.07.2018 20:48

I really very like your videos

Ответить
Tech Item
Tech Item - 17.07.2018 20:48

Please sir I have error in custom broadcast receiver in oreo.
Not work.
So please give me suggestions

Ответить
Tech Item
Tech Item - 17.07.2018 20:46

But please put video custom broadcast receiver in oreo because it will not work in oreo.


All your android tutorial give me deep knowledge

Ответить