Frage

i want when the user open the application to play a song and when the song is finish a new activity will be fired, i put a skip button to allow the user to stop the song and go to the next activity, this is the code

timer = new Thread() {
            public void run() {
                try {
                    sleep(13000);
                } catch (InterruptedException e) {
                    // TODO: handle exception
                } finally {
                    Intent openStartingPoing = new Intent(
                            "com.localizedbasedcompetition.SIGNIN");// action
                                                                    // name
                    startActivity(openStartingPoing);
                }
            }
        };
        timer.start();

and this is the onclick for skip button

public void onClick(View v) {
        // TODO Auto-generated method stub
        switch (v.getId()) {
        case R.id.bSplashSkip:
            timer.stop();
            Intent openStartingPoing = new Intent(
                    "com.localizedbasedcompetition.SIGNIN");// action name
            startActivity(openStartingPoing);
            break;

        default:
            break;
        }
    }

and that code works good , i mean if i click the skip button the song is stop and new activity is lunched, but my problem is even if also is good , i got an exception (but the application still works) and the application is

07-05 13:34:19.687: E/global(26114): Deprecated Thread methods are not supported.
07-05 13:34:19.687: E/global(26114): java.lang.UnsupportedOperationException
07-05 13:34:19.687: E/global(26114):    at java.lang.VMThread.stop(VMThread.java:85)
07-05 13:34:19.687: E/global(26114):    at java.lang.Thread.stop(Thread.java:1280)
07-05 13:34:19.687: E/global(26114):    at java.lang.Thread.stop(Thread.java:1247)
07-05 13:34:19.687: E/global(26114):    at com.localizedbasedcompetition.Splash.onClick(Splash.java:73)
07-05 13:34:19.687: E/global(26114):    at android.view.View.performClick(View.java:2552)
07-05 13:34:19.687: E/global(26114):    at android.view.View$PerformClick.run(View.java:9229)
07-05 13:34:19.687: E/global(26114):    at android.os.Handler.handleCallback(Handler.java:587)
07-05 13:34:19.687: E/global(26114):    at android.os.Handler.dispatchMessage(Handler.java:92)
07-05 13:34:19.687: E/global(26114):    at android.os.Looper.loop(Looper.java:130)
07-05 13:34:19.687: E/global(26114):    at android.app.ActivityThread.main(ActivityThread.java:3701)
07-05 13:34:19.687: E/global(26114):    at java.lang.reflect.Method.invokeNative(Native Method)
07-05 13:34:19.687: E/global(26114):    at java.lang.reflect.Method.invoke(Method.java:507)
07-05 13:34:19.687: E/global(26114):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
07-05 13:34:19.687: E/global(26114):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
07-05 13:34:19.687: E/global(26114):    at dalvik.system.NativeStart.main(Native Method)
War es hilfreich?

Lösung

Use timer.interrupt() instead of .stop(). Thread.stop() is deprecated, as your Log says.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top