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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:15:08+00:00 2026-05-26T11:15:08+00:00

I’ve built an appWidget which register some services on his onEnabled() method. The problem

  • 0

I’ve built an appWidget which register some services on his onEnabled() method.

The problem is that after I use the built in Task Manager’s Clean Memmory/Ram, the appWidget view crashes (all the appWidgets TextView’s text is set to default (TextView)) and the Services stop running and never restarts.

This only happen after some time the widget is set, and if I Clean Memmory/Ram right after the widget is set the bug does’nt happen, but I guess this is related to the Task Manager’s method of cleaning RAM.

So finally, my question is: Is there a way to tell the android system to reStart those services? as other appWidgets I’ve downloaded through the market is seem to continue working fine after this procedure.

Will be happy for ideas and solutions! Thanks advanced, Gal 🙂

some code that I use:

the onEnabled() method in the appWidget:

@Override
public void onEnabled(Context context) {
    super.onEnabled(context);

    Intent newinIntent = new Intent(context, CallService_1x1.class);
        context.startService(newinIntent);

    newinIntent = new Intent(context, SmsService_1x1.class);
        context.startService(newinIntent);
}

Some methods from one of the Services (others services are very similiar as this is from their abstract method):

 @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
      // We want this service to continue running until it is explicitly
      // stopped, so return sticky.
      Log.d("SERVICE-SMS","CallMonitorService - onStartCommand created");
      return START_STICKY;
  } 

@Override
  public void onCreate() {
    super.onCreate();
    context = this.getApplicationContext();
    Log.d("SERVICE-SMS","CallMonitorService created");
    registerObserver();
  }

@Override
  public void onStart(Intent intent, int startId) {
    super.onStart(intent, startId);
  }

  @Override
  public void onDestroy() {
    unregisterObserver();
    super.onDestroy();
  }

  @Override
  public IBinder onBind(Intent intent) {
    return null;
  }
  /**
   * Start the service to process that will run the content observer
   */
  public static void beginStartingService(Context context) {
   Log.d("SERVICE-SMS","CallMonitorService: beginStartingService()");
    context.startService(new Intent(context, CallService.class));
  }

  /**
   * Called back by the service when it has finished processing notifications,
   * releasing the wake lock if the service is now stopping.
   */
  public static void finishStartingService(Service service) {
    Log.d("SERVICE-SMS","CallMonitorService: finishStartingService()");
    service.stopSelf();
  }
  • 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-05-26T11:15:09+00:00Added an answer on May 26, 2026 at 11:15 am

    After a lot of research and some attempts, Solved it! 🙂

    Just added BroadcastReciever listening to package changes and updates:

    register receiver in the manifest file:

    <receiver android:name=".receivers.onRestartReciever">
            <intent-filter>
                <action android:name="android.intent.action.PACKAGE_REPLACED" />
                <action android:name="android.intent.action.PACKAGE_RESTARTED" />
                <data android:scheme="package" android:path="my.Package.Path" />
            </intent-filter>
    
    • PACKAGE_REPLACED – called in particular to notify application update.
    • PACKAGE_RESTARTED – called when most memmory cleaners are cleaning memmory.
    • the “data” row is used to monitor action applied for the specific package.

    Within this reciever I start my services again, and restarts the widget view (calling it’s onUpdate() method in this case):

    public class onRestartReciever extends BroadcastReceiver {
    
    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        Log.d("DEBUG", "onRestartReciever");
    
        // Register Services
        MyWidget_1x1.registerServices(context);
        MyWidget_2x2.registerServices(context);
    
        // reInitialize appWidgets
        AppWidgetManager appWidgetManager=AppWidgetManager.getInstance(context);
    
        MyWidget_1x1 widget1x1=new CallWidgi();
        widget1x1.onUpdate
        (context,
             AppWidgetManager.getInstance(context),
                widget1x1.getIDs(context, appWidgetManager));
    
        MyWidget_2x2 widget2x2=new CallWidgi2();
        widget2x1.onUpdate(context,
                            AppWidgetManager.getInstance(context),
                                widget2x2.getIDs(context, appWidgetManager));
        }
    }
    

    registerServices(Context) is a static method in my AppWidgetProvider classes (MyWidget_1x1/MyWidget_2x2) which registers the needed services.

    Hope it will help you too =]

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into

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.