Note that there are some explanatory texts on larger screens.

plurals
  1. POApp crashing on button click
    primarykey
    data
    text
    <p>Whenever I click my button my app crashes. What am I doing wrong?</p> <pre><code>public void onClick(View v) { int primaryLength = PRIMARY.length; final String primaryText = PRIMARY[rnd.nextInt(primaryLength)]; int secondaryLength = SECONDARY.length; final String secondaryText = SECONDARY[rnd.nextInt(secondaryLength)]; final TextView textOne = (TextView)findViewById(R.id.textView1); final TextView textTwo = (TextView)findViewById(R.id.textView2); textOne.setText(primaryText); textTwo.setText(secondaryText); String primeT = primaryText; Uri media = Uri.parse(primeT); mpButtonOne = MediaPlayer.create(MainActivity.this, media); mpButtonOne.start(); mpButtonOne.setOnCompletionListener(new OnCompletionListener() { public void onCompletion(MediaPlayer mpButtonOne) { String primeS = secondaryText; Uri media2 = Uri.parse(primeS); mpButtonTwo = MediaPlayer.create(MainActivity.this, media2); mpButtonTwo.start(); mpButtonTwo.setOnCompletionListener(new soundListener1()); { } } </code></pre> <p>I want the randomly selected text that is displayed in textviews to be entered as the location for the mediaplayer sound files, the words are the names of the sound files in my raw folder. I'm a bit new and really not sure if this is the right way to go about it.</p> <pre><code>09-11 16:50:40.128: E/AndroidRuntime(12531): FATAL EXCEPTION: main 09-11 16:50:40.128: E/AndroidRuntime(12531): java.lang.NullPointerException 09-11 16:50:40.128: E/AndroidRuntime(12531): at com.spunktrunk.nastylittleman.MainActivity$1.onClick(MainActivity.java:62) 09-11 16:50:40.128: E/AndroidRuntime(12531): at android.view.View.performClick(View.java:2408) 09-11 16:50:40.128: E/AndroidRuntime(12531): at android.view.View$PerformClick.run(View.java:8816) 09-11 16:50:40.128: E/AndroidRuntime(12531): at android.os.Handler.handleCallback(Handler.java:587) 09-11 16:50:40.128: E/AndroidRuntime(12531): at android.os.Handler.dispatchMessage(Handler.java:92) 09-11 16:50:40.128: E/AndroidRuntime(12531): at android.os.Looper.loop(Looper.java:123) 09-11 16:50:40.128: E/AndroidRuntime(12531): at android.app.ActivityThread.main(ActivityThread.java:4669) 09-11 16:50:40.128: E/AndroidRuntime(12531): at java.lang.reflect.Method.invokeNative(Native Method) 09-11 16:50:40.128: E/AndroidRuntime(12531): at java.lang.reflect.Method.invoke(Method.java:521) 09-11 16:50:40.128: E/AndroidRuntime(12531): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:876) 09-11 16:50:40.128: E/AndroidRuntime(12531): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:634) 09-11 16:50:40.128: E/AndroidRuntime(12531): at dalvik.system.NativeStart.main(Native Method) 09-11 16:50:40.128: W/ActivityManager(237): Force finishing activity com.spunktrunk.nastylittleman/.MainActivity </code></pre>
    singulars
    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.
 

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