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

The Archive Base Latest Questions

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

I have widget that start 2 services using AlaramManager and running them repeatedly: public

  • 0

I have widget that start 2 services using AlaramManager and running them repeatedly:

public static final String TAG = "RotterWidgetProvider";
public static ArrayList<SubjectObject> subjectsList;
public static boolean isUpdated=true;
public static int currentSubject=0;
private PendingIntent serviceShowNextSubject = null;  
private PendingIntent serviceDownloadSubjects = null;
Intent i=null;
Intent i2=null;

@Override
public void onUpdate(final Context context, final AppWidgetManager appWidgetManager,int[] appWidgetIds) 
{
  RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.rotter_appwidget_layout);
  Intent launchAppIntent = new Intent(context, WidgetSettings.class);
  PendingIntent launchAppPendingIntent = PendingIntent.getActivity(context,
           0, launchAppIntent, PendingIntent.FLAG_UPDATE_CURRENT);
     remoteView.setOnClickPendingIntent(R.id.imgWidgetSettings, launchAppPendingIntent);
  if(subjectsList==null)
  {
     remoteView.setTextViewText(R.id.txtSubject,"נא לחכות, טוען נתונים");
     ComponentName RotterListWidget = new ComponentName(context,
                RotterWidgetProvider.class);
        appWidgetManager.updateAppWidget(RotterListWidget, remoteView);

       final AlarmManager m = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);  

        final Calendar TIME = Calendar.getInstance();  
        TIME.set(Calendar.MINUTE, 0);  
        TIME.set(Calendar.SECOND, 0);  
        TIME.set(Calendar.MILLISECOND, 0);  

        if(i==null)
        {
           i = new Intent(context, UpdateRotterWidgetService.class); 
           Log.v(TAG,"UpdateRotterWidgetService Created");
        }
        if(i2==null)
        {
           i2 = new Intent(context, DownloadSubjectsService.class); 
           Log.v(TAG,"DownloadSubjectsService Created");
        }

        if (serviceShowNextSubject == null)  
        {  
           serviceShowNextSubject = PendingIntent.getService(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); 
           Log.v(TAG,"serviceShowNextSubject initialized");
        }  
        if(serviceDownloadSubjects==null)
        {
           serviceDownloadSubjects=PendingIntent.getService(context, 0, i2, PendingIntent.FLAG_CANCEL_CURRENT); 
           Log.v(TAG,"serviceDownloadSubjects initialized");
        }

        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
        String subjectsDownloadInterval=settings.getString("SubjectsDownloadInterval", "10");
        String subjectsUpdateInterval=settings.getString("SubjectsUpdateInterval", "10");
        int down=10;
        int upd=10;
        try
        {
           down=Integer.parseInt(subjectsDownloadInterval);
           upd=Integer.parseInt(subjectsUpdateInterval);
        }
        catch(Exception e)
        {

        }
        m.setRepeating(AlarmManager.RTC, TIME.getTime().getTime(), 1000 * 60*down, serviceDownloadSubjects);
        m.setRepeating(AlarmManager.RTC, TIME.getTime().getTime(), 1000 * upd, serviceShowNextSubject); 


  }
}

After i delete Widget from the screen i am cancelling the services:

@Override  
public void onDisabled(Context context)  
{  
    final AlarmManager m = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);  
    m.cancel(serviceShowNextSubject);  
    m.cancel(serviceDownloadSubjects); 


} 

But the services not cancelling and keep running in background.
What can be the problem?

  • 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-05T10:05:03+00:00Added an answer on June 5, 2026 at 10:05 am

    Cancelling the alarms won’t stop the services. You have to either stop them manually, or have time stop themselves after they finish their work.

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

Sidebar

Related Questions

I have a widget that customers buy to put on their site. We're running
I have a widget that, when pressed, sends a broadcast that starts a CountDownTimer
I have a home-screen widget that has an icon that starts/so pose to bring
I have a widget that includes 2 image views. When I resize the widget,
I have a widget that acts as a launcher on the home screen. How
I have a widget that supposed to call an Activity of the main app
I have created a widget that is being hosted on a number of websites.
I have a JavaScript widget that is hosted on websites. This widget tracks state
I have a jquery widget that get data from a server in another domain
I have a custom QTextEdit widget that has it's own resize grip in the

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.