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

  • Home
  • SEARCH
  • 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 9009297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:09:10+00:00 2026-06-16T02:09:10+00:00

I have a widget created for my app to launch. The data in the

  • 0

I have a widget created for my app to launch. The data in the widget is getting updated after 30mins. I need to reduce the timing to around 2mins. I have heard that it can be done using AlarmService but I have no idea about how it should be implemented. I am sharing my widget code.

public class SampleWidget extends AppWidgetProvider {
    @Override
    public void onUpdate(Context context, AppWidgetManager appWidgetManager,
            int[] appWidgetIds) {
        // TODO Auto-generated method stub
        super.onUpdate(context, appWidgetManager, appWidgetIds);
        RemoteViews view;
        SampleDatabase linksDatabase = new SampleDatabase(context);
        linksDatabase.openDb();
        List<MyMedia> myMedias = linksDatabase.getData();
        String date = null;
        String level = null;
        for (int j = 0; j < myMedias.size(); j++) {
            date = myMedias.get(j).getDateTime();
            level = myMedias.get(j).getLevel();
        }

        linksDatabase.closeDb();
        if (myMedias != null && myMedias.size() > 0) {

            for (int i = 0; i < myMedias.size(); i++) {
                final int n = appWidgetIds.length;
                for (int j = 0; j < n; j++) {
                    int appWidget = appWidgetIds[j];
                    Intent intnt = new Intent(context, MainActivity.class);
                    PendingIntent pi = PendingIntent.getActivity(context, 0,
                            intnt, 0);
                    view = new RemoteViews(context.getPackageName(),
                            R.layout.widget_layout);
                    view.setOnClickPendingIntent(R.id.relLayout, pi);
                    view.setTextViewText(R.id.date, date);
                    //view.setTextViewText(R.id.time, obtainedTime);
                    StringBuffer sb = new StringBuffer(level);
                    sb.append(" ");
                    sb.append("units");
                    view.setTextViewText(R.id.value_1, sb.toString());
                    appWidgetManager.updateAppWidget(appWidget, view);

                }

            }

        }
    }
}

Can anyone help me in finding a way for implementing. Thanks

  • 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-16T02:09:11+00:00Added an answer on June 16, 2026 at 2:09 am

    I got the solution for this and it is that you have to write a service where you will be updating the text and you will need to call the AlarmManager for every 2mins. In the service class you will be accessing the data by creating a database object and getting the details which updates the text in the widget.

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

Sidebar

Related Questions

I have created an App Widget for Android 1.5. It uses a TextView to
I have created an app which retrieves the data from a url using xml
I have a speedometer widget I have created in my app using custom animation
In my Android app, I have an Activity with a Spinner widget. I created
I have created an app widget which, when clicked, launches an Activity in my
I have created an app widget in Android and want to add some gesture-based
I have created a widget for my app. Everything works fine, but the only
I have created a view like this Ext.define('App.view.Message', { extend: 'Ext.Panel', alias: 'widget.message', config:
I have created a widget in my application , now when a widget is
i have created a custom post type named Books & i have a widget

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.