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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:15:17+00:00 2026-05-30T15:15:17+00:00

I tried solving my problem using this link update – I figured out that

  • 0

I tried solving my problem using this link

update – I figured out that there is something wrong with the setter of the pending intent- every time I click on the imageview- the intent sends the extre details of the last defined widget-
meaning that the other pending intents that where defined on the pre-added widgets were run-over by the newer widgets

I have an app widget that shows a picture chosen by the user.(many widgets- many pictures)
my problem is: no matter which widget on screen I press – only the last added widget gets updated:
here is my code

My Widget xml provider Code

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
    android:initialLayout="@layout/widget_Test"
    android:minHeight="146dip"
    android:minWidth="146dip"
    android:updatePeriodMillis="0" />

My Manifest xml code

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.test"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

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

    <application
            android:icon="@drawable/icon"
            android:label="@string/app_name" >
            <activity
                    android:name=".Activities.WidgetConfig"
                    android:screenOrientation="portrait" >

                    <!-- prbbly delete this line -->
                    <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
            </activity>
            <!-- Test Widget -->
            <receiver
                    android:name=".Simple.Widget"
                    android:label="@string/app_widget_Test" >
                    <intent-filter>
                            <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
                    </intent-filter>

                    <meta-data
                            android:name="android.appwidget.provider"
                            android:resource="@xml/widget_Test_provider" />
            </receiver>

            <service android:name=".Simple.Widget$TestWidgetService" />
    </application>

</manifest>

Widget provider

public class Widget extends AppWidgetProvider
{
    public static String PREFENCES_WIDGET_CONFIGURE = "ActionConfigureWidget";
    public  static int[] widgets;

    @Override
    public void onUpdate(Context context, AppWidgetManager appWidgetManager,
                    int[] appWidgetIds)
    {
            Intent svcIntent = new Intent(context, TESTWidgetService.class);
            widgets = appWidgetIds;
            context.startService(svcIntent);
    }

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

                    // Push update to homescreen
                    Mngr.getInstance().pushUpdate(remoteView,
                                    getApplicationContext(), Widget.class);

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

            public RemoteViews buildRemoteView(Context context)
            {
                    RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
                                    R.layout.widget_TEST);
                    if (widgets != null)
                    {
                            int length = widgets.length;

                            for (int i = 0; i < length; i++)
                            {
                                    Intent configIntent = new Intent(context,
                                                    WidgetConfig.class);

                                    configIntent.setAction(Widget.PREFENCES_WIDGET_CONFIGURE);
                                    String number = AppWidgetManager.EXTRA_APPWIDGET_ID
                                                    + "number";
                                    configIntent.putExtra(number, length);
                                    String widgetID = AppWidgetManager.EXTRA_APPWIDGET_ID + i;
                                    int id = widgets[i];
                                    configIntent.putExtra(widgetID, id);
                                    PendingIntent runTESTPendingIntent = PendingIntent
                                                    .getActivity(context, 0, configIntent,
                                                                    PendingIntent.FLAG_UPDATE_CURRENT);

                                    remoteViews.setOnClickPendingIntent(R.id.TESTWidgetImage,
                                                    runTESTPendingIntent);

                                    Mngr controller = Mngr.getInstance();

                                    controller.updateTESTWidget(context, remoteViews);
                            }
                    }
                    return remoteViews;
            }

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

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

                            // Push update to homescreen
                            Mngr.getInstance().pushUpdate(remoteView,
                                            getApplicationContext(), Widget.class);
                    }
            }

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

my config activity

public class WidgetConfig extends ListActivity // implements
{
    private Bundle m_extras;
    private ArrayList<Test> m_tests = null;
    private int mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
    ImageAdapter m_adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.imagelist);

            Resources res = getResources();
            Mngr mngr = Mngr.getInstance();
            mngr.setResources(res);
            Context ctx = getApplicationContext();
            mngr.setContext(ctx);
            getTests();
            m_adapter = new ImageAdapter(ctx, R.layout.row, m_tests);
            ImageDownloader.Mode mode = ImageDownloader.Mode.CORRECT;
            m_adapter.getImageDownloader().setMode(mode);

            setListAdapter(m_adapter);

            Intent intent = getIntent();
            m_extras = intent.getExtras();
    }

    private void getTests()
    {
            m_tests = new ArrayList<Test>();

            Resources res = getResources();
            String[] TestNames = res.getStringArray(R.array.fav_Test_array);
            TypedArray imgs = getResources().obtainTypedArray(
                            R.array.fav_Test_integer);
            for (int i = 0; i < TestNames.length; i++)
            {
                Test o1 = new Test();
                String TestName = TestNames[i];
                int resID = imgs.getResourceId(i, -1);
                o1.setTestName(TestName);
                o1.setIMGID(resID);
                m_tests.add(o1);
            }
            imgs.recycle();

    }

    @Override
    protected void onListItemClick(ListView l, View v, int position, long id)
    {

        ListAdapter adapt = l.getAdapter();
        Object obj = adapt.getItem(position);
        if (obj != null)
        {
            Mngr mngr = Mngr.getInstance();
            Context context = getApplicationContext();
            String key = context.getString(R.string.TestWidget_string) + "_"
                + AppWidgetManager.EXTRA_APPWIDGET_ID;
            Test Test = (Test) obj;
            String val = Test.getIMGID().toString();
            mngr.putString(context, key, val);
            updateWidget();
        }

        super.onListItemClick(l, v, position, id);
    }

    private void updateWidget()
    {
        Context ctx = getApplicationContext();
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(ctx);
        setResult(RESULT_CANCELED);
        if (m_extras != null)
        {
            Intent resultValue = new Intent();

            int numberOfWidgets = m_extras.getInt(
                AppWidgetManager.EXTRA_APPWIDGET_ID + "number",
                AppWidgetManager.INVALID_APPWIDGET_ID);
            for (int i = 0; i < numberOfWidgets; i++)
            {

                String stringID = AppWidgetManager.EXTRA_APPWIDGET_ID + i;
                mAppWidgetId = m_extras.getInt(stringID,
                                AppWidgetManager.INVALID_APPWIDGET_ID);


                /*************************************************************/
                /*I Don't really know if I am using this piece of code right */
                Uri data = Uri.withAppendedPath(Uri.parse("ABCD"
                                + "://widget/id/"), String.valueOf(mAppWidgetId));
                resultValue.setData(data);
                /*************************************************************/

                RemoteViews views = new RemoteViews(ctx.getPackageName(),
                                R.layout.widget_Test);

                Mngr.getInstance().updateTestWidget(ctx, views);

                appWidgetManager.updateAppWidget(mAppWidgetId, views);
                resultValue.putExtra(stringID, mAppWidgetId);
            }

            setResult(RESULT_OK, resultValue);
            finish();
        }
    }
}

My Mngr code

public void updateTestWidget(Context context, RemoteViews remoteViews)
{
    String key = context.getString(R.string.TestWidget_string) + "_"
            + AppWidgetManager.EXTRA_APPWIDGET_ID;

    String s = getString(context, key, "");
    if (s != null && s.equals("") == false)
    {
        int resID = Integer.valueOf(s);
        remoteViews.setImageViewResource(R.id.TestWidgetImage, resID);
    }
}

public void pushUpdate(RemoteViews remoteView, Context ctx, Class<?> cls)
{
    ComponentName myWidget = new ComponentName(ctx, cls);
    AppWidgetManager manager = AppWidgetManager.getInstance(ctx);
    manager.updateAppWidget(myWidget, remoteView);
}
  • 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-30T15:15:19+00:00Added an answer on May 30, 2026 at 3:15 pm

    The problem isn’t your configActivity, the problem is in your widgetProvider. I had the same problem as you did but solved using the link you specified. You need to set the “hacked” intent on your configIntent in buildRemoteView.

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

Sidebar

Related Questions

Tried something like this: HttpApplication app = s as HttpApplication; //s is sender of
Tried this: $('.link').click(function(e) { $.getScript('http://www.google.com/uds/api?file=uds.js&amp;v=1.0', function() { $('body').append('<p>GOOGLE API (UDS) is loaded</p>'); }); return
To get acquainted with Mathematica's solving functions, I tried to work out a solution
This is driving me nuts, lots of similar problems out there on the web,
I'm solving a problem that consist in generate the first n<1000000 lucky numbers, but
I was looking for solving a LCS problem (Longest common subsequence) and I tried
I have a problem using Jquery. I do this: $(#ID_ESTADO).change(function() { document.getElementById(inprogress).style.visibility = visible;
I am using codeigniter 2 in my project and I have a problem that
Tried examples from 'php.net' but don't understand what's the problem. Any suggestions? <?php $_SESSION['test']
tried to research on that but sometimes I seem to lack some googling skills...

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.