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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:54:31+00:00 2026-06-05T12:54:31+00:00

In my main activity, I have a method setRepeatingAlarm() to set the Alarms when

  • 0

In my main activity, I have a method setRepeatingAlarm() to set the Alarms when the app first loads. That method successfully sets the Alarms by looping through a column and taking an integer value from each row in a SQLite table. Here is the method in basic:

 for (int i : AlarmDays) {


        Calendar cal = Calendar.getInstance();
        if (cal.get(Calendar.MINUTE) >= i)
            cal.add(Calendar.HOUR, 1);
        cal.set(Calendar.MINUTE, i);

        Intent intent = new Intent(ManageDebts.this, TimeAlarm.class);
        pendingIntent = PendingIntent.getBroadcast(this, i,
                intent, PendingIntent.FLAG_CANCEL_CURRENT);
        am.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(),
                60 * 60 * 1000, pendingIntent);
    }

After the Method is completed it then loops through the rows each again and puts each into a CustomAdapter (List) to display the data. Here is the context (again, in basic) in my onCreate in the main class:

    datasource = new DebtDataSource(this);
    datasource.open();

    **am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    setRepeatingAlarm();**

    values = datasource.getAllDebt();
    adapter = new MyArrayAdapter(this, values);
    setListAdapter(adapter);

I want the user to either long press a row and it will delete the item, or there is a button to delete all rows. Everything works, but I can not get the alarms to go away.

I understand HOW to do this (cancel method by setting same pendingIntent with the same extras), but my attempts have been foiled! and I dont know WHERE to put it? Everything above is in the same class.

Whether the user deletes one row or all, I think the easy way is to delete all Alarms and loop through that method again to reset them. Can anyone help out and tell me where to put this canceling code?

  • 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-05T12:54:33+00:00Added an answer on June 5, 2026 at 12:54 pm

    In Long click of the List

    PendingIntent pi = PendingIntent.getBroadcast(context, unique_id, i, 0);
    am.cancel(pi);
    

    unique_id is seperate for every pending intent so get the listview id , add +1 so that it will be your pending intent ID.

    So that that particluar PendingIntent will be deleted.

    To Cancel all the alarms Make a for loop simply as you set the alarm and Cancel them.

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

Sidebar

Related Questions

I have an android app that has mutliple activities The first main activity starts
I have a widget that supposed to call an Activity of the main app
In my main activity, I would like to have it set up, so that
I have a main activity that takes elements from a database and displays them
I have a simple main activity with 3 buttons, and a background service that
I have an Android application with a main activity that is the tabhost. I'm
I have following simple method in my main activity. private void showMap(String name )
i have problems with my game. I have an Main Activity that's shows a
I have a main Activity and some static variables (got values in onCreate() method).
I have an app with 3 activites. At my opening activity (main activity), 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.