how to set message in alarm ?

In alarm app, user gives input String for alarm message and sets alaram. I am able to set and listen alarm.but how to display message set by user? have set many times to set alarm, how can i display respective message for that specific alarm


You should have an onReceive(Context context, Intent intent) function in your BroadcastReceiver. It looks something like:

public void onReceive(Context context, Intent intent) {   
    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, ""); // Second argument is an arbitrary String tag

    // Put YOUR code here (between WaitLocks)
    String userInputtedString = intent.getBundleExtra("UserText")
    Toast.makeText(context, userInputtedString, Toast.LENGTH_LONG).show();


In order to get that Bundle you have to pass in an intent extra when creating the alarm

Intent intent = new Intent(context, AlarmNotification.class);
intent.putExtra("UserText", userInputedString);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);

I just showed an example of a Toast message, but you can change that to a Notification or AlertDialog also. Let me know if this helps.

Need Your Help

zip and download files using php

php zip

I am trying to zip and download files from a folder named "upload".

Regular expression(Write regular expression for only one alphabet

c# javascript .net

I want to write a validation regular expression for strings that come in the format of