Vinay W
Vinay W

Reputation: 10190

Code works on Gingerbread (2.3.6) not on ICS (4.0.4)

01-10 18:35:44.372: E/AndroidRuntime(18378): FATAL EXCEPTION: Timer-1 01-10 18:35:44.372: E/AndroidRuntime(18378): java.lang.IllegalStateException: Must be called from main thread of process 01-10 18:35:44.372: E/AndroidRuntime(18378): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1373) 01-10 18:35:44.372: E/AndroidRuntime(18378): at android.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:437) 01-10 18:35:44.372: E/AndroidRuntime(18378): at android.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:454) 01-10 18:35:44.372: E/AndroidRuntime(18378): at android.app.Activity.onBackPressed(Activity.java:2134) 01-10 18:35:44.372: E/AndroidRuntime(18378): at com.vwap.friends.MygoBack(MyDialog.java:90) 01-10 18:35:44.372: E/AndroidRuntime(18378): at com.vwap.friends.MyDialog$3.run(MyDialog.java:83) 01-10 18:35:44.372: E/AndroidRuntime(18378): at java.util.Timer$TimerImpl.run(Timer.java:284)

I don't know where to begin from. Do i start by reading about Fragments or can i quickly fix this and release my application?

Upvotes: 3

Views: 1319

Answers (3)

Ajax -the Max
Ajax -the Max

Reputation: 1069

Even I am facing a similar problem, but i think you have to include android_support_v4.jar file for compatibility over all versions of Android.

Upvotes: 0

Ahmad
Ahmad

Reputation: 72603

You're performing a network operation on the main thread. If your target SDK is 11 or higher this will throw a NetworkOnMainThreadException , because this behaviour can block the UI and lead to an unresponsive app.

You could use an AsyncTask to get around this, loading the data in its doInBackground(..).

Upvotes: 2

Bhavesh Patadiya
Bhavesh Patadiya

Reputation: 25830

try to Use runOnUiThread(Runnable action).

Or

you can Also Try with Handler:

final Runnable YOURVIEW = new Runnable()
{
    public void run() 
    {
        SampleMethod(); // Put your Method What you want change
        handler.postDelayed(this, timeout);
    }
};

handler.postDelayed(changeView, timeout);

Upvotes: 1

Related Questions