Android - Broadcast Receiver

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ม.ค. 2025

ความคิดเห็น • 22

  • @alvisvadaliya3299
    @alvisvadaliya3299 5 ปีที่แล้ว +4

    Sir,
    here 9:17 you have made a mistake that is out of the scope of , and still program worked fine. because you have corrected that mistake at off-screen Recording, it would be great if you tell us that where and what you have changed after correcting that mistake.

    • @MayankCodes
      @MayankCodes 3 ปีที่แล้ว

      What should be the correct code then?

  • @jacobkanyi5046
    @jacobkanyi5046 2 ปีที่แล้ว +3

    nice video, but you are talking too fast making your words unclear.

  • @lapzap8127
    @lapzap8127 5 ปีที่แล้ว +10

    speak slow and properly(suggestion)

  • @hrishikeshsutar4198
    @hrishikeshsutar4198 5 ปีที่แล้ว +4

    Speak slow and proper

  • @tejapa3710
    @tejapa3710 5 ปีที่แล้ว +2

    sir you please mice because sometimes I can't here your voice clearly

  • @moforemmanuel158
    @moforemmanuel158 5 ปีที่แล้ว +3

    great video and explanation, but your voice is a little funny

  • @YashSharmaUP80
    @YashSharmaUP80 5 ปีที่แล้ว

    Nice Video Sir

  • @JayTailor45
    @JayTailor45 6 ปีที่แล้ว

    Thank you, Mr.Aditya.

  • @OasisFinder
    @OasisFinder 6 ปีที่แล้ว

    Nice video (y)

  • @newlife-vx9vz
    @newlife-vx9vz 4 ปีที่แล้ว

    Hello, Merry Christmas! Thank you for sharing your knowledge. Can Broadcast Receiver be used to programmatically read other apps such as Messenger, Viber and Whatsapp ? .. without opening the respective app (of course with user permission). Thank you for acknowledging my question.

  • @khezarbangash337
    @khezarbangash337 5 ปีที่แล้ว

    thank you

  • @renat19831983
    @renat19831983 5 ปีที่แล้ว

    Thank you!

  • @abkhan3700
    @abkhan3700 6 ปีที่แล้ว

    Main activity:
    public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button button=(Button)findViewById(R.id.button);
    button.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
    Intent i=new Intent();
    i.setAction("com.example.abbaskhan.sendbroadcast");
    i.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
    sendBroadcast(i);
    Log.i("in after click","NA");
    }
    });
    }
    Reciver class:
    class MyReciver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
    Toast.makeText(context,"broadcast recived",Toast.LENGTH_LONG).show();
    }
    }
    Manifist file :






    Still code not working Toast not showing any thing .......help me out here

    • @metalvarez1
      @metalvarez1 6 ปีที่แล้ว +2

      I had the same problem I managed to solve this by registering the receiver class in my activity, check the code below.
      public class MainActivity extends AppCompatActivity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      Button button = findViewById(R.id.button);
      MyCustomBroadCastReceiver customReceiver = new MyCustomBroadCastReceiver();
      registerReceiver(customReceiver, new IntentFilter("com.ejemplo.curso.broadcastrecieverexample.CUSTOM_INTENT"));
      button.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
      Intent intent = new Intent();
      Log.d("MainActivity.button.setOnClickListener", "Sending intent");
      intent.setAction("com.ejemplo.curso.broadcastrecieverexample.CUSTOM_INTENT");
      sendBroadcast(intent);
      }
      });
      }
      }
      another thing I found is that there is not needed to add the receiver tag in AndroidManifest.xml file, It will work just registering the custom receiver inside the MainActivity class

    • @bhushanugale3185
      @bhushanugale3185 5 ปีที่แล้ว

      @@metalvarez1 Thanks for this help....this works for me...Thanks a lot

  • @nimishamanocha761
    @nimishamanocha761 4 ปีที่แล้ว

    Speak properly .

  • @fayazmughal07
    @fayazmughal07 4 ปีที่แล้ว

    Muh khol

  • @asifa3621
    @asifa3621 2 ปีที่แล้ว

    IntentFilter intentFilter = new IntentFilter("android.CUSTOM_INTENT");
    MyReceiver myReceiver = new MyReceiver();
    registerReceiver(myReceiver, intentFilter);
    The above 3 lines missing in oncreate of Activity