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 9148469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:16:53+00:00 2026-06-17T11:16:53+00:00

I’m trying to make a simple alarm trigger. When alarm goes off there should

  • 0

I’m trying to make a simple alarm trigger. When alarm goes off there should a a simple sound alarm. But the alarm doesn’t go off, nothing happens. Now I’m not sure where am I mistaken – is it the times? Intents? Receivers?

Class in which I’m using AlarmManager

package com.example.prva;


import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;

import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.TimePicker;

public class Meni_Splash extends Activity{  
    Calendar c = Calendar.getInstance();
    private int hour = c.get(Calendar.HOUR_OF_DAY);
    private int minute = c.get(Calendar.MINUTE);
    int milivreme;
    int milipicker;
    long sveskupa;
    int hoursad;
    int minutesad;
    protected boolean timeactive = true;
    Handler h=new Handler();


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);             
        h.post(new Runnable(){
            @Override
            public void run() {
                String currentDateTimeString = DateFormat.getDateTimeInstance().format(new Date());
                TextView text = (TextView) findViewById(R.id.textDate);
                text.setText(currentDateTimeString);
                h.postDelayed(this, 1000);
            }
        });     


        final TimePicker picker = (TimePicker) findViewById(R.id.timePicker);
        final TextView text = (TextView) findViewById(R.id.texttime);

        picker.setIs24HourView(true);       
        picker.setCurrentHour(hour);
        picker.setCurrentMinute(minute);

        Button btnt = (Button) findViewById(R.id.buttontime);       



        btnt.setOnClickListener(new View.OnClickListener() {


            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                hoursad = picker.getCurrentHour();
                minutesad = picker.getCurrentMinute();
                milipicker = (((hoursad) * 60 * 60 * 1000) + ((minutesad) * 60 * 1000));
                text.setText(new StringBuilder().append(hoursad).append(":").append(minutesad).append( "Trenutno vrijeme u milisekundama : ").append(System.currentTimeMillis()).append(" vrijeme izabrano u milisekundama sve skupa ").append(milipicker));
            }
        });

        Button btnalarm = (Button) findViewById(R.id.btnalarm);
        btnalarm.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                hoursad = picker.getCurrentHour();
                minutesad = picker.getCurrentMinute();
                milivreme = (((hour)* 60 * 60 * 1000)+ ((minute) * 60 * 1000));     
                milipicker = (((hoursad) * 60 * 60 * 1000) + ((minutesad) * 60 * 1000));
                sveskupa = milipicker - milivreme;

                Intent intent = new Intent(Meni_Splash.this, AlarmReceiver.class);
                PendingIntent pendingintent = PendingIntent.getActivity(Meni_Splash.this, 2, intent, PendingIntent.FLAG_CANCEL_CURRENT);

                AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
                am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + sveskupa, pendingintent);                      

            }
        });

        Button btnv = (Button) findViewById(R.id.buttonv);
        btnv.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                startActivity(new Intent(Meni_Splash.this, button.class));              
            }
        });             
    }   
}

AlarmReceiver class :

package com.example.prva;

import android.app.Activity;
import android.media.MediaPlayer;
import android.os.Bundle;


public class AlarmReceiver extends Activity {
    protected MediaPlayer MPAlarm;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        MPAlarm = MediaPlayer.create(this, R.raw.splash);
        MPAlarm.start();
    }




};
  • 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-17T11:16:54+00:00Added an answer on June 17, 2026 at 11:16 am

    Look like there problem in AlarmManager set() function.

    AlarmManager Set() =>

    public void set (int type, long triggerAtMillis, PendingIntent operation)

    Parameters
    type One of ELAPSED_REALTIME, ELAPSED_REALTIME_WAKEUP, RTC or RTC_WAKEUP.
    triggerAtMillis time in milliseconds that the alarm should go off, using the appropriate clock (depending on the alarm type).
    operation Action to perform when the alarm goes off; typically comes from IntentSender.getBroadcast().

    Please note that operation (PendingIntent), will get the action from IntentSender.getBroadcast().
    Hope it’s helps.

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping a

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.