javaandroidandroid-studio-2.1

How to RECEIVE_EMERGENCY_BROADCAST messages from android devices


I want to receive Emergency cell Broadcasting messages in my application. For this, I want permission RECEIVE_EMERGENCY_BROADCAST. And i have to import some android OS classes com.android.internal.telephony.ITelephony. But I can't access those classes in my application. Please do help me out this problem or can anyone can tell me how to access android hidden OS functions?


Solution

  • Declare a broadcast receiver class in manifest with following filters

    <intent-filter android:priority="999<action android:name="android.provider.Telephony.SMS_CB_RECEIVED" /></intent-filter>       <intent-filter><action android:name="android.provider.Telephony.CB_RECEIVED" />
    

    In the broadcast receiver class we will get the intent in following overrided method.

    public void onReceive(Context paramContext, Intent paramIntent) {
    }
    

    Extratct the "paramIntent" for getting the Cell Broadcast message.