My application runs on android 2.3.3 for android 3.1, but stops with an error on 4.0 +

I just published my first Android app yesterday. I have not tested on Android 4.0, and my friend just told me that my application is breaking about its Galaxy S2 (4.0.3)

This is crashing after a few seconds in my splash screen activity, these are just a few lines of code, maybe you guys can check it out:

 @Override
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splashscreen);

    try
    {

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    overridePendingTransition(0 , 0);

    // thread for displaying the SplashScreen
    Thread splashTread = new Thread() {
        @Override
        public void run() {
            try {
                int waited = 0;
                while(_active && (waited < _splashTime)) {
                    sleep(100);
                    if(_active) {
                        waited += 100;
                    }
                }
            } catch(InterruptedException e) {
                // do nothing
            } finally {
               // finish();

                try
                {
                  /*
                   Intent i = new Intent();
                    i.setClass(SplashScreen.this, MainActivity.class);
                    startActivity(i);
                    finish();
                    */
                }
                catch(Exception e)
                {
                    ki(e);
                }

                stop();
            }
        }
    };

    splashTread.start();

    }
    catch(Exception ex)
    {
        ki(ex);
    }

 }

@Override
public void onBackPressed() {
   return;
}   



 //Toaster
    public void ki(Exception message)
    {


    Toast myToast = Toast.makeText(getApplicationContext(), message.toString(), 1);
    myToast.show();

}

Works fine on Android 2.3 to 3.1, but I can't figure out what the problem is with 4.0+

Please help thank you!

Edit:

If I remove my thread, everything will be fine. So me a new question ... What's new in streams in 4.0? I just ran a thread that does nothing, and even I got a crash.

+5
source share
4

, stop() Android 4.0. finish(), .

+5

Thread.stop(), resume() suspend() Android 4.0. :

/**
 * Requests the receiver Thread to stop and throw ThreadDeath. The Thread is
 * resumed if it was suspended and awakened if it was sleeping, so that it
 * can proceed to throw ThreadDeath.
 *
 * @deprecated because stopping a thread in this manner is unsafe and can
 * leave your application and the VM in an unpredictable state.
 */
@Deprecated
public final void stop() {
    stop(new ThreadDeath());
}

/**
 * Throws {@code UnsupportedOperationException}.
 *
 * @throws NullPointerException if <code>throwable()</code> is
 *         <code>null</code>
 * @deprecated because stopping a thread in this manner is unsafe and can
 * leave your application and the VM in an unpredictable state.
 */
@Deprecated
public final synchronized void stop(Throwable throwable) {
    throw new UnsupportedOperationException();
}

- Android 4.0. Google; Java SDK stop() .

:

Commit: a7ef55258ac71153487357b861c7639d627df82f [a7ef552]
Author: Elliott Hughes <enh@google.com>
Date: 2011-02-23 6:47:35 GMT+08:00

Simplify internal libcore logging.

Expose LOGE and friends for use from Java. This is handy because it lets me use
printf debugging even when I've broken String or CharsetEncoder or something
equally critical. It also lets us remove internal use of java.util.logging,
which is slow and ugly.

I've also changed Thread.suspend/resume/stop to actually throw
UnsupportedOperationException rather than just logging one and otherwise
doing nothing.

Bug: 3477960
Change-Id: I0c3f804b1a978bf9911cb4a9bfd90b2466f8798f
+8

@Yuku , Thread.stop() - ICS, , , :

http://developer.android.com/reference/java/lang/Thread.html#stop()

- (Throwable throwable)

: API 1 . VM .

UnsupportedOperationException. NullPointerException, throwable() null

, , threadName.interrupt() . - , , .

stop(), , , run().

EDIT finish() - Activity , Thread. Thread , , , Thread Activity, .

+7

, stop() ICS.

My tutorial on droidnova.com is not updated to work on ICS, sorry, I didn’t. Today I would use a handler instead of a separate thread. Much easier to use and more reliable.

+3
source

All Articles