Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Retrieving string from php page using split from the * character
    text
    copied!<p>Can someone please tell my why this causes my application to crash? This same code works on my other application that's why I'm so confused.</p> <p>What I am trying to do is tell my application to go to <a href="http://omarcomputerservices.com/cartoons/cartoons.php?getCartoon&amp;ID=1" rel="nofollow">http://omarcomputerservices.com/cartoons/cartoons.php?getCartoon&amp;ID=1</a> and then split the parsed string from the '*' character. Then add it to the array.</p> <p>I have added the internet permission. </p> <pre><code>package com.omarreyes.youtubechannels; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; import android.app.Activity; public class StartingPoint extends Activity { ArrayList&lt;String&gt; images = new ArrayList&lt;String&gt;(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_starting_point); Button get = (Button) findViewById(R.id.button1); get.setOnClickListener(listener); } private OnClickListener listener = new OnClickListener() { public void onClick(View v) { getImages(); } }; private void getImages() { try { // Create a URL object URL url = new URL("http://omarcomputerservices.com/cartoons/cartoons.php?getCartoon&amp;ID=1"); // Read all of the text returned by the HTTP server BufferedReader in = new BufferedReader (new InputStreamReader(url.openStream())); String htmlText; while ((htmlText = in.readLine()) != null) { // Keep in mind that readLine() strips the newline characters String[] data = htmlText.split("\\*"); images.add(data[0].toString()); } in.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } </code></pre>
 

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