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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:13:52+00:00 2026-06-10T18:13:52+00:00

I am building a Widget which contains a ProgressBar. If the Widget is computing

  • 0

I am building a Widget which contains a ProgressBar. If the Widget is computing I set the visibility of that ProgressBar to VISIBLE, and to INVISIBILE if all computings stopped. There should be no Problem, because the setVisibility is documented as RemotableViewMethod. However some guys at HTC seem to forget it, (i.e on the Wildfire S), so a call to RemoteViews.setVisibility will result in a crash. For this reason I try to implement a check, if setVisibility is really callable. I have writen this Method for it:

private boolean canShowProgress(){
        LogCat.d(TAG, "canShowProgress");
        Class<ProgressBar> barclz = ProgressBar.class;
        try {
            Method method = barclz.getMethod("setVisibility", new Class[]{int.class});
            Annotation[] anot = method.getDeclaredAnnotations();
            return anot.length > 0;
        } catch (SecurityException e) {
            LogCat.stackTrace(TAG, e);
        } catch (NoSuchMethodException e) {
            LogCat.stackTrace(TAG, e);
        }
        return false;
    }

This will work, but is REALLY ugly as it will return `True´ if ANY Annotiation is present. I looked, how RemoteView itself is doing the lookup and found this:

if (!method.isAnnotationPresent(RemotableViewMethod.class)) {
                throw new ActionException("view: " + klass.getName()
                        + " can't use method with RemoteViews: "
                        + this.methodName + "(" + param.getName() + ")");
            }

But i could’t do the same, because the Class RemotableViewMethod is not accsesible through the sdk. How to know if it is accesible or not?

  • 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-10T18:13:54+00:00Added an answer on June 10, 2026 at 6:13 pm

    By Writing my question I had the Idea to lookup for the class by its Name, and it worked.
    So I updated my Method to the following:

    private boolean canShowProgress(){
            LogCat.d(TAG, "canShowProgress");
            Class<ProgressBar> barclz = ProgressBar.class;
            try {
                Method method = barclz.getMethod("setVisibility", new Class[]{int.class});
                Class c = null;
                try {
                    c = Class.forName("android.view.RemotableViewMethod");
                } catch (ClassNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                return (this.showProgress= (c != null && method.isAnnotationPresent(c)));
    
    
            } catch (SecurityException e) {
                LogCat.stackTrace(TAG, e);
            } catch (NoSuchMethodException e) {
                LogCat.stackTrace(TAG, e);
    
            }
            return false;
        }
    

    which works flawlessly

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

Sidebar

Related Questions

I'm following this tutorial on building a widget IN that tutorial, he's testing whether
I'm building a widget which allows user to copy items from one list over
I am building a small widget that I am giving to users to embed
I am building an application which has GtkMenu widget. I am using Glade RAD
I am building a web widget which will be very easy to integrate. Say
I have been building widget that accept user input and then once everything checked
Basically, I'm building a little widget for a site, and I need to set
I'm building a homescreen widget and my goal is to set an image on
I'm building an app which helps in searching just like Google's search widget. In
I've been asked to look into building a widget for a website that looks

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.