Broadcastreceiver in notifications

Asked

Viewed 68 times

0

Eae guys I’m novice in the issue of android I’m with the following doubt

I’m making an application that sends notifications every day at times determined by the user but I did not find content on the internet about this just a few videos but they are very bad . Amid my researches I came across the Broadcastreceiver only that I do not know how to implement it if someone can help me in this.

1 answer

0


The documentation of Broadcasts is here. Inside the page has exemplary implementations.

<receiver android:name=".MyBroadcastReceiver"  android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
        <action android:name="android.intent.action.INPUT_METHOD_CHANGED" />
    </intent-filter>
</receiver>


public class MyBroadcastReceiver extends BroadcastReceiver {
    private static final String TAG = "MyBroadcastReceiver";
    @Override
    public void onReceive(Context context, Intent intent) {
        StringBuilder sb = new StringBuilder();
        sb.append("Action: " + intent.getAction() + "\n");
        sb.append("URI: " + intent.toUri(Intent.URI_INTENT_SCHEME).toString() + "\n");
        String log = sb.toString();
        Log.d(TAG, log);
        Toast.makeText(context, log, Toast.LENGTH_LONG).show();
    }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.