Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8920547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:18:00+00:00 2026-06-15T06:18:00+00:00

What does alarmmanager really do? Is it the one that really plays the sound

  • 0

What does alarmmanager really do? Is it the one that really plays the sound or just some kind of trigger? I’m trying to make an application that will play an alarm even in silent mode when received a sms with a certain keyword, then display an alert dialog that will provide the user with buttons to press to reply to the message. I’ve been studying and finding working examples online for about a week but none of them even play the alarm. plus, the examples are always different and confusing that just gets me more frustrated. I’m a newbie in android app dev. please help me.. thanks in advance. here is my code

public class EAlarmReceiver extends BroadcastReceiver {

public static String sender;
public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    Bundle bundle = intent.getExtras(); 
    Object[] pdusObj = (Object[]) bundle.get("pdus"); 
    SmsMessage[] messages = new SmsMessage[pdusObj.length]; 
    for (int i = 0; i<pdusObj.length; i++) 
    { 
            messages[i] = SmsMessage.createFromPdu ((byte[]) 
            pdusObj[i]); 
            sender = messages[i].getOriginatingAddress();
    } 

    for (SmsMessage msg : messages) {
        if (msg.getMessageBody().contains("alert")) {
            Calendar cal = Calendar.getInstance();
            cal.add(Calendar.SECOND, 5);
            Intent i = new Intent(context, ReceiverInterface.class);
            PendingIntent pendingIntent = PendingIntent.getActivity(context,
                12345, i, PendingIntent.FLAG_CANCEL_CURRENT);
            AlarmManager am = (AlarmManager)context.getSystemService(Activity.ALARM_SERVICE);
            am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),
                    pendingIntent);
        }//end if
    }//end for

}// end onreceive
}

I’m sorry if the code was really messy

public class ReceiverInterface extends Activity{
final Context context = this;
String my_password = "1234";
AlertDialog.Builder alertDialogBuilder;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.receiverinterface);

   alertDialogBuilder = new AlertDialog.Builder(
            context);
    alertDialogBuilder.setTitle("Emergency signal received");

            alertDialogBuilder
            .setMessage("Click availability status")
            .setCancelable(false)
            .setPositiveButton("available",new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog,int id) {
                    dispatch_available_action();
                    Toast.makeText(getApplicationContext(), "available", Toast.LENGTH_LONG).show();
                }
              })
            .setNegativeButton("not available",new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog,int id) {
                    // if this button is clicked, just close
                    // the dialog box and do nothing
                    dialog.cancel();
                }
            });

            // create alert dialog
            AlertDialog alertDialog = alertDialogBuilder.create();

            // show it
            alertDialog.show();

}// end oncreate()


public void dispatch_available_action(){
    final EditText password_input = new EditText(this); // create an text input field
    password_input.setHint("Enter Password"); // put a hint in it
    password_input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); // change it to password type

    alertDialogBuilder = new AlertDialog.Builder(
            context);
    AlertDialog.Builder alertDialog = new Builder(this); // create an alert box
    alertDialog.setTitle("Enter Password"); // set the title
    alertDialog.setView(password_input);  // insert the password text field in the alert box
    alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { // define the 'OK' button
        public void onClick(DialogInterface dialog, int which) {
             String entered_password = password_input.getText().toString();
             if (entered_password.equals(my_password)) {
                 alertDialogBuilder.setTitle("Send status");

                 alertDialogBuilder.setCancelable(false);
                 alertDialogBuilder.setPositiveButton("Yes",new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,int id) {

                            try {

                            String message = "available";
                            SmsManager smsManager = SmsManager.getDefault();
                            EAlarmReceiver eReceiver = new EAlarmReceiver();
                            String eSender = eReceiver.sender;
                            Toast.makeText(getApplicationContext(), eSender,
                                    Toast.LENGTH_LONG).show();
                            smsManager.sendTextMessage(eSender, null, message, null, null);

                            } catch (Exception e) {
                                Toast.makeText(getApplicationContext(),
                                "SMS failed, please try again later!",
                                Toast.LENGTH_LONG).show();
                                e.printStackTrace();
                            }
                        }
                      });
                    alertDialogBuilder.setNegativeButton("No",new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,int id) {
                            // if this button is clicked, just close
                            // the dialog box and do nothing
                            dialog.cancel();
                        }
                    });
                    // create alert dialog
                    AlertDialog alertDialog = alertDialogBuilder.create();

                    // show it
                    alertDialog.show();

             } else {
                 Toast.makeText(getApplicationContext(),
                        "Wrong password!",
                        Toast.LENGTH_LONG).show();
             }
        } 
    });
    alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { // define the 'Cancel' button
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        } 
    });
    alertDialog.show(); // show the alert box
}
}

The alertdialog is working fine, I just can’t get the alarm to ring, let alone do it while in silent mode.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:18:02+00:00Added an answer on June 15, 2026 at 6:18 am

    All AlarmManager does is execute a PendingIntent at a given time, with an optional repeat. It has nothing to do with audio streams. This howto will probably help you play a sound when your PendingIntent is received.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that does some data processing, then notifies the user in
I am trying to create an app that will send some data to a
I have an application that calls AlarmManager Intent intent; intent = new Intent(context, MyEventReceiver.class);
My AlarmManager does not work properly. The LogCat says that setting alarm to turn
I'm doing one application like raising email intent by time using AlarmManager . In
I'm writing an application which needs to make some work every 5 seconds, if
Android's AlarmManager Javadoc states When an alarm goes off, the Intent that had been
In the app I am working on, I have an AlarmManager that starts a
I've an application that has a widget already and have a service which updates
In my Android app I have a service that is started via AlarmManager. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.