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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:49:40+00:00 2026-06-07T20:49:40+00:00

I newbie at programming Android and I try to do a widget which has

  • 0

I newbie at programming Android and I try to do a widget which has be able get some data from ISP about my account. There are a lot of unknown things how to do it, but I have did a few things – I’ve got a widget with configure activity, where user should type login and password. Widget stores the data in SharedPerferences, and when it’s time to update widget I use a Service to start an AsyncTask to getting it from ISP an account data. Now I want to do start an activity by click on widget. I’ve tried all advice which I found on this site and widget can’t start activity. My widget based on another widget which placed here https://github.com/Arturus/MetrikaWidget. I dont understand what and where I should change to start activity by clicking on my widget. Thanks.

UPDATE:
My update function, where I suggest I should place PendingIntent

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds)
{
    Log.d(TAG, "onUpdate");

    for (int appWidgetId : appWidgetIds)
    {
        updateAppWidget(context, appWidgetManager, appWidgetId);
    }

    /* An updateAppWidget functions looks like as:

    Intent intent = new Intent(context, UpdateWidgetService.class);
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);
    context.startService(intent);
    */

    Intent intent = new Intent(context, DetailedStatActivity.class);
    PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, 0);

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

    views.setOnClickPendingIntent(R.id.layout, pendingIntent);

    ComponentName componentName = new ComponentName(context.getPackageName(), WidgetProvider.class.getName());

    appWidgetManager.updateAppWidget(componentName, views);
}
  • 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-07T20:49:43+00:00Added an answer on June 7, 2026 at 8:49 pm

    Use this snippet in onUpdate() method of your widget AppWidgetProvider class:

    @Override
    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
        RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widgetlayout);
        Intent configIntent = new Intent(context, Activity.class);
    
        PendingIntent configPendingIntent = PendingIntent.getActivity(context, 0, configIntent, 0);
    
        remoteViews.setOnClickPendingIntent(R.id.widget, configPendingIntent);
        appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);
    }     
    

    Here widgetlayout is name of your widget layout and R.id.widget is it’s parent layout id.

    Edit:
    Now,I see your code that you added to your question.You would to do:

    PendingIntent.getActivity(context, 0, configIntent, 0);
    

    (that start’s activity) instead of

    PendingIntent.getService(...);
    

    that attempt to starts service.Good luck.

    References:
    doityourselfandroid.com

    helloandroid.com

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

Sidebar

Related Questions

I am a complete Android programming newbie. I have completed some tutorial examples like
I'm a completely newbie to android programming, having done some java for my computing
I'm a programming newbie and am having some trouble understanding an example from my
Hi I'm a newbie in Android Programming. I'm trying to build an activity which
I'm a erlang newbie. When I read the Socket chapter from Programming Erlang and
I've read about phonegap which enables users to write web-based apps for android and
I'm a newbie to programming and need some help with the set of fixers
I am a long time OO programmer and a functional programming newbie. From my
I'm a newbie to Android programming and I've been whacking my head over how
I am a newbie to programming and need some help with the basics. 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.