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);
}
}
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.