Opened 6 weeks ago

Closed 6 weeks ago

#2631 closed defect (fixed)

java.lang.IllegalStateException: at

Reported by: Meeh Owned by: Meeh
Priority: minor Milestone: 0.9.43
Component: apps/android Version: 0.9.42
Keywords: Cc:
Parent Tickets: Sensitive: no


  at (
  at (
  at$5.onClick (
  at$AlertParams$3.onItemClick (
  at android.widget.AdapterView.performItemClick (
  at android.widget.AbsListView.performItemClick (
  at android.widget.AbsListView$ (
  at android.widget.AbsListView$ (
  at android.os.Handler.handleCallback (
  at android.os.Handler.dispatchMessage (
  at android.os.Looper.loop (
  at (
  at java.lang.reflect.Method.invoke (Native Method)
  at$ (
  at (


Change History (5)

comment:1 Changed 6 weeks ago by idk

I found this Stack Overflow question that looks like a very similar problem. I'm looking to see if this applies to us and whether we can use the same solution.

comment:2 Changed 6 weeks ago by zzz

I don't think the above-linked SO page is relevant. The exception is being thrown in Fragment.getResources(), via our onClick() method. Javadoc says it returns Activity.getResources() which is from ContextThemeWrapper?. As there's no associated message, may take a tour through the source or more googling to find out why.

comment:3 Changed 6 weeks ago by zzz

We have lots of getResources() calls in fragments. The issue is apparently that the fragment got 'detached' and we need to 'reattach' it? Not clear how to detect detachment and/or reattach.

comment:4 Changed 6 weeks ago by zzz

fragment lifecycle:
onAttach() is called before onStart() which calls checkDialog() so the problem is it got detached.

How about this which would get the resources in advance? (untested)

--- app/src/main/java/net/i2p/android/router/	b6d53a9da7a552964fc256d20d5eaa623c5a06a9
+++ app/src/main/java/net/i2p/android/router/	052b5ea292c3d1a899db5424e3cca9491f6c342d
@@ -578,12 +578,13 @@ public class MainFragment extends I2PFra
         if (language == null) {
             AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
+            final String languages[] = getResources().getStringArray(R.array.languages);
                     .setItems(R.array.language_names, new DialogInterface.OnClickListener() {
                         public void onClick(DialogInterface dialog, int which) {
                             // Save the language choice
-                            String language = getResources().getStringArray(R.array.languages)[which];
+                            String language = languages[which];
                                     .putString(getString(R.string.PREF_LANGUAGE), language)

comment:5 Changed 6 weeks ago by zzz

Milestone: undecided0.9.43
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.