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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:44:23+00:00 2026-06-02T11:44:23+00:00

I have an appwidget, that creates an object (passing its context) and then calling

  • 0

I have an appwidget, that creates an object (passing its context) and then calling a static method on some other class.

The call to the static method throws NullPointerException and I have no idea why.

Here’s the code:

public String[] g(int count, Boolean h) {       

    String[] result = MyFactory.g(mContext, mDb, count, h);

    if (result != null) {
        m = result.length;
    }
    else {
        m = 0;
    }

    return result;

}

The exception is thrown at MyFactory.g . g is a static function.

What can be null here?

It seems to happen to some of my users, but not on my device… frustrating.

Thanks.

btw: I’m using proguard on my app, is it possible that because of proguard I don’t get the entire stack trace (inside the static function) ?

MyFactory class:

public class MyFactory {


public static String[] g(Context mContext, SQLiteDatabase db, int count, boolean hasShortcut) {

    SharedPreferences prefs = 
        mContext.getSharedPreferences(A.SHARED_PREFS_NAME, 0);

    int type = Integer.parseInt(prefs.getString(mContext.getString(R.string.pref_type_key), "0"));


    switch (type) {
        case 1:
            return T1.g(db, count, hasShortcut);

    }

    return D1.g(db, count, hasShortcut);        

}


}
  • 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-02T11:44:24+00:00Added an answer on June 2, 2026 at 11:44 am

    I have no idea what the problem was, but I just copied the static function code to the non-static calling function and it worked.

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

Sidebar

Related Questions

I have a Button on appwidget, that I need to 'enable'/'disable' programmatically from a
I have an application with some AppWidget s. I'm storing some information about every
So currently I have code, in C++, that creates a few QLabels, a QLineEdit,
How do I write a function that adds a method to a class? I
I have created an AppWidget for Honeycomb which is working well, except that when
I have a widgetProvider . I also have a service class that does the
I have an AppWidget that has a StackView contained within it. Along with the
I have a Widget with his android.appwidget.action.APPWIDGET_CONFIGURE Activity with some preferences witch I can
Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
Have a matrix report now that has Position, Hours and Wages for a location

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.