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.
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.
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
IntentFilter intentFilter = new IntentFilter("android.CUSTOM_INTENT"); MyReceiver myReceiver = new MyReceiver(); registerReceiver(myReceiver, intentFilter); The above 3 lines missing in oncreate of Activity
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.
What should be the correct code then?
nice video, but you are talking too fast making your words unclear.
speak slow and properly(suggestion)
So humble, nice!
Speak slow and proper
sir you please mice because sometimes I can't here your voice clearly
great video and explanation, but your voice is a little funny
Yes Bro 😆 You are Right
Nice Video Sir
Thank you, Mr.Aditya.
Nice video (y)
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.
thank you
Thank you!
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
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
@@metalvarez1 Thanks for this help....this works for me...Thanks a lot
Speak properly .
Muh khol
IntentFilter intentFilter = new IntentFilter("android.CUSTOM_INTENT");
MyReceiver myReceiver = new MyReceiver();
registerReceiver(myReceiver, intentFilter);
The above 3 lines missing in oncreate of Activity