Note that there are some explanatory texts on larger screens.

plurals
  1. POActivity get Force Close when running story line with Intent Timer
    primarykey
    data
    text
    <p>Can anyone check my code? Thanks in advance. I have made a story line which is automatically goes to another activity using <code>Intent</code> and <code>Timer</code>. I put a background music and a sound which is the speech of the character in my story line. But when i get to the fifth <code>Activity</code> it Force Close and Gets error in my logcat. </p> <p>Here's my code in my Story line <code>Activity</code>: Page 1 is ok but i paste my code also:</p> <pre><code>public class pgone extends Activity { protected boolean _active = true; protected int _splashTime = 7000; public void onAttachedToWindow() { super.onAttachedToWindow(); Window window = getWindow(); window.setFormat(PixelFormat.RGBA_8888); } MediaPlayer audio; MediaPlayer SLONE; private long splashDelay = 6000; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pgone); //StartAnimations(); TimerTask task = new TimerTask() { public void run() { Intent mainIntent = new Intent().setClass(pgone.this, pgtwo.class); startActivity(mainIntent); finish(); } }; final Timer timer = new Timer(); timer.schedule(task, splashDelay); audio = MediaPlayer.create(this,R.raw.storyaud); audio.start(); SLONE = MediaPlayer.create(this,R.raw.sl1); SLONE.start(); if(SLONE.isPlaying()==false) { SLONE.release(); } final MediaPlayer mp = MediaPlayer.create(this, R.raw.buttonbeep); final Vibrator mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); Button skipButton = (Button)findViewById(R.id.skip); skipButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent skipIntent = new Intent(pgone.this,choose.class); startActivity(skipIntent); mp.start(); mVibrator.vibrate(500); finish(); timer.cancel(); timer.purge(); } }); } } </code></pre> <p>Page 2 is ok. Page 3 is ok. </p> <p>And here's my Page 4 i get error when going to the Fifth page. And also the sound "speech of the Characters" is overlapping with each other. :</p> <pre><code>public class pgfour extends Activity { public void onAttachedToWindow() { super.onAttachedToWindow(); Window window = getWindow(); window.setFormat(PixelFormat.RGBA_8888); } MediaPlayer mp1; MediaPlayer sl4juststaycalm; MediaPlayer sl4ucandoitdoc; MediaPlayer sl4waa; private long splashDelay = 7000; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pgfour); TimerTask task = new TimerTask() { public void run() { Intent mainIntent = new Intent().setClass(pgfour.this, pgfive.class); startActivity(mainIntent); finish(); } }; final Timer timer = new Timer(); timer.schedule(task, splashDelay); sl4juststaycalm = MediaPlayer.create(this,R.raw.sl4juststaycalm); sl4ucandoitdoc = MediaPlayer.create(this,R.raw.sl4ucandoitdoc); sl4waa = MediaPlayer.create(this,R.raw.sl4waa); sl4juststaycalm.start(); if(sl4juststaycalm.isPlaying()==false) { sl4ucandoitdoc.start(); } if(sl4ucandoitdoc.isPlaying()==false) { sl4waa.start(); } final MediaPlayer mp = MediaPlayer.create(this, R.raw.buttonbeep); final Vibrator mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); Button skipButton = (Button)findViewById(R.id.skip); skipButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent skipIntent = new Intent(pgfour.this,choose.class); startActivity(skipIntent); mp.start(); mVibrator.vibrate(500); finish(); timer.cancel(); timer.purge(); } }); } @override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { moveTaskToBack(true); return true; // return } return false; } @override public void run() { finish(); } } </code></pre> <p>Here's my Page 5 and i get error when my Page 4 is going to this activity.</p> <pre><code>public class pgfive extends Activity { public void onAttachedToWindow() { super.onAttachedToWindow(); Window window = getWindow(); window.setFormat(PixelFormat.RGBA_8888); } MediaPlayer mp1; MediaPlayer sl5idontknow; MediaPlayer sl5whathappeningdoc; MediaPlayer sl6parts; private long splashDelay = 7000; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pgfive); TimerTask task = new TimerTask() { public void run() { Intent mainIntent = new Intent().setClass(pgfive.this, pgsix.class); startActivity(mainIntent); finish(); } }; final Timer timer = new Timer(); timer.schedule(task, splashDelay); sl5idontknow = MediaPlayer.create(this,R.raw.sl5idontknow); sl5whathappeningdoc = MediaPlayer.create(this,R.raw.sl5whathappeningdoc); sl6parts = MediaPlayer.create(this,R.raw.sl6parts); sl5idontknow.start(); if(sl5idontknow.isPlaying()==false) { sl5whathappeningdoc.start(); } if(sl5whathappeningdoc.isPlaying()==false) { sl6parts.start(); } final MediaPlayer mp = MediaPlayer.create(this, R.raw.buttonbeep); final Vibrator mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); Button skipButton = (Button)findViewById(R.id.skip); skipButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent skipIntent = new Intent(pgfive.this,choose.class); startActivity(skipIntent); mp.start(); mVibrator.vibrate(500); finish(); timer.cancel(); timer.purge(); } }); } @override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { moveTaskToBack(true); return true; // return } return false; } @override public void run() { finish(); } } </code></pre> <p>Here's my Log Cat:</p> <pre><code>08-22 09:24:03.135: E/AndroidRuntime(222): Uncaught handler: thread main exiting due to uncaught exception 08-22 09:24:03.144: E/AndroidRuntime(222): java.lang.RuntimeException: Unable to start activity ComponentInfo{drj.thesis.tridi/drj.thesis.tridi.pgfive}: java.lang.NullPointerException 08-22 09:24:03.144: E/AndroidRuntime(222): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496) 08-22 09:24:03.144: E/AndroidRuntime(222): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 08-22 09:24:03.144: E/AndroidRuntime(222): at android.app.ActivityThread.access$2200(ActivityThread.java:119) 08-22 09:24:03.144: E/AndroidRuntime(222): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863) 08-22 09:24:03.144: E/AndroidRuntime(222): at android.os.Handler.dispatchMessage(Handler.java:99) 08-22 09:24:03.144: E/AndroidRuntime(222): at android.os.Looper.loop(Looper.java:123) 08-22 09:24:03.144: E/AndroidRuntime(222): at android.app.ActivityThread.main(ActivityThread.java:4363) 08-22 09:24:03.144: E/AndroidRuntime(222): at java.lang.reflect.Method.invokeNative(Native Method) 08-22 09:24:03.144: E/AndroidRuntime(222): at java.lang.reflect.Method.invoke(Method.java:521) 08-22 09:24:03.144: E/AndroidRuntime(222): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) 08-22 09:24:03.144: E/AndroidRuntime(222): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 08-22 09:24:03.144: E/AndroidRuntime(222): at dalvik.system.NativeStart.main(Native Method) 08-22 09:24:03.144: E/AndroidRuntime(222): Caused by: java.lang.NullPointerException 08-22 09:24:03.144: E/AndroidRuntime(222): at drj.thesis.tridi.pgfive.onCreate(pgfive.java:59) 08-22 09:24:03.144: E/AndroidRuntime(222): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 08-22 09:24:03.144: E/AndroidRuntime(222): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459) 08-22 09:24:03.144: E/AndroidRuntime(222): ... 11 more </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload