Inside my Android app , I created a simple Broadcastreceiverclass and also Added it it Manifest file.
Now my question is , how does the Android know which Broadcastreceiver class to call, if all we can add inside the Menifest file is the actions under eceiver tag.
Also , is it such that we can only create one Broadcasreceiver class in a Android app ?
or we can create multiple number of Broadcastreceiver class ?
ADDED IN MANIFEST FILE :
<receiver android:name=".MyBroadcast">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.AIRPLANE_MODE"/>
</intent-filter>
</receiver>
BROADCASTRECEIVER CLASS :
package com.deepesh.broadcastapp;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
public class MyBroadcast extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())){
Toast.makeText(context, "Boot completed !", Toast.LENGTH_SHORT).show();
Log.d("Keyy","Boot completed !");
}else if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(intent.getAction())){
Toast.makeText(context, "Airplane mode changed !", Toast.LENGTH_SHORT).show();
Log.d("Keyy","Airplane mode changed ! !");
}
}
}
What I have tried:
Tried google but no specific answer to my query I guess