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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:02:16+00:00 2026-06-09T18:02:16+00:00

I’m trying to start a service from my widget provider to update the widget

  • 0

I’m trying to start a service from my widget provider to update the widget on orientation change. The problem is that the service does not seem to start. Can anyone see what I’m doing wrong? This is all I have in my code for now.

public class PSWidgetProvider extends AppWidgetProvider {

    private static Handler      handler             = new Handler();
    private static Runnable     runnable;
    public static int           currentAlarmSet     = 0;

    @Override
    public void onReceive(final Context context, Intent intent) {
        // TODO Auto-generated method stub
        super.onReceive(context, intent);

    }

    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {

        context.startService(new Intent(context, MyUpdateService.class));

    }


    public static class MyUpdateService extends Service
    {
        @Override
        public void onStart(Intent intent, int startId)
        {
            Log.i("MyUpdateService", "onStart");
            super.onStart(intent, startId);
            // Update the widget
            RemoteViews remoteViews = buildRemoteView(this);

            // Push update to homescreen
            pushUpdate(remoteViews);

            // No more updates so stop the service and free resources
            stopSelf();
        }

        public RemoteViews buildRemoteView(Context context)
        {
            RemoteViews updateViews = null;

            updateViews = new RemoteViews(context.getPackageName(), R.layout.widget_powersleep_layout);
            // Your code to build and update the remote view


            return updateViews;
        }

        @Override
        public void onConfigurationChanged(Configuration newConfig)
        {
            int oldOrientation = this.getResources().getConfiguration().orientation;

            if(newConfig.orientation != oldOrientation)
            {
                // Update the widget
                RemoteViews remoteViews = buildRemoteView(this);

                // Push update to homescreen
                pushUpdate(remoteViews);
            }
        }

        private void pushUpdate(RemoteViews remoteViews)
        {
            ComponentName myWidget = new ComponentName(this, PSWidgetProvider.class);
            AppWidgetManager manager = AppWidgetManager.getInstance(this);
            manager.updateAppWidget(myWidget, remoteViews);
        }

        @Override
        public IBinder onBind(Intent arg0) {
            // TODO Auto-generated method stub
            return null;
        }
    }

}

My Manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.am.pn"
    android:versionCode="7"
    android:versionName="1.1.7" >

    <uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="14" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".activity.PSActivity"
            android:label="@string/title_activity_p_s" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <receiver android:name=".receiver.PSWidgetProvider" >
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
                <action android:name="android.appwidget.action.APPWIDGET_ENABLED"/> 
            </intent-filter>

            <meta-data
                android:name="android.appwidget.provider"
                android:resource="@xml/widget_config" />
        </receiver>
        <receiver
            android:name=".receiver.AlarmReceiver"
            android:process=":remote" >
        </receiver>

        <service
            android:name=".receiver.PSWidgetProvider.MyUpdateService"
            android:process=":configservice"
            android:enabled="true"
            android:exported="true"
             android:configChanges="keyboardHidden|orientation" >
        </service>
    </application>

</manifest>
  • 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-09T18:02:17+00:00Added an answer on June 9, 2026 at 6:02 pm

    Figured it out, the service name should have read android:name=".receiver.PSWidgetProvider$MyUpdateService"
    since it is a static inner class.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I am currently running into a problem where an element is coming back from
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
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
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.