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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:19:23+00:00 2026-06-12T03:19:23+00:00

My app contains an activity which UI has to be updated due to server

  • 0

My app contains an activity which UI has to be updated due to server show schedule. What is the best approach for updating UI in this situation.

So far, I’ve come up with AlarmManager and Service but I’m not sure it’s a good practice. Any other suggestions ? I’ve seen some relevant methods in Handler but I’m not how to use them regarding the uptime parameter.

Alarm

    Intent intent = new Intent(getActivity(), OnAirUpdateAlarmReceiver.class);
    PendingIntent sender = PendingIntent.getBroadcast(getActivity(),
            0, intent, 0);

    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());
    calendar.add(Calendar.SECOND, 10);

    AlarmManager am = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE);
    am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender);

Receiver (checks whether the running activity is one the needs to updated)

@Override
public void onReceive(Context context, Intent intent) {
    ActivityManager am = (ActivityManager) context
            .getSystemService(Activity.ACTIVITY_SERVICE);
    List<ActivityManager.RunningTaskInfo> taskInfo = am.getRunningTasks(1);
    String name = taskInfo.get(0).topActivity.getShortClassName();
    if (name.equals(".activity.handset.HandsetMainActivity")) {
        Intent notificationIntent = new Intent(context,
                HandsetMainActivity.class);
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
                | Intent.FLAG_ACTIVITY_NEW_TASK);
        notificationIntent.putExtra(
                context.getResources().getString(
                        R.string.extras_main_activity_on_new_intent),
                HandsetMainActivity.UPDATE_PLAYER_FRAGMENT_UI);
        context.startActivity(notificationIntent);
    }
}

And if it is – requests fragments UI update. Again not sure if this is the best solution.

Thanks for your suggestions.

  • 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-12T03:19:25+00:00Added an answer on June 12, 2026 at 3:19 am

    Well, you know when your application is visible ‘onStart() / onStop()’ at this point you can start a TimerTask.

    I guess if you are only updating the UI it doesn’t have to happen when the user doesnt have your app opened.

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

Sidebar

Related Questions

My app starts up at Activity A which contains a ListView. The ListView can
I am building an app which contains a list of addresses. This app is
I am using fragments to show images/pages.I have one Activity(Main) which contains all the
I have an app which has a main activity that calls other activities on
I have an Activity which extends MapActivity (to show a MapView) and contains a
I have an app which contains an activity which is a MapviewActivity and is
My android app is simple : a single activity contains a webview which shows
I have an app that contains several activities...so lets say user is navigating activity
This is a toy project I'm working on at the moment. My app contains
I have an app which contains a scrollview with several tableviews. Each tableview is

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.