Echo the content of a TextView?

Mariocci Rossini

I have a class with this code

public boolean busybox() throws IOException
{

        try
        {

        Process p =Runtime.getRuntime().exec("busybox");
        InputStream a = p.getInputStream();
        InputStreamReader read = new InputStreamReader(a);
        BufferedReader in = new BufferedReader(read);
        StringBuilder buffer = new StringBuilder();

        String line = null;

        try {

            while ((line = in.readLine()) != null) {
                buffer.append(line);
            }

        } finally {
            read.close();
            in.close();
        }

        String result = buffer.toString().substring(0, 15);
        System.out.println(result);

        return true;
        } catch (Exception e) {
        e.printStackTrace();
    }

        return false;
        }

In another class I have this code

try {
    if(root.busybox()) {

        Busybox.setText(Html.fromHtml((getString(R.string.busybox))));


    }
    else {

        Busybox.setText(Html.fromHtml((getString(R.string.no))));

    }
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
            }
        });

If I want to write in this TextView the outpout generated by System.out.println(result);

How can i do? Thanks in advance! I made several attempts, but I have several errors and the code is wrong.

Ketan Ahir

change return type of public boolean busybox() to string like public String busybox() and return result.

then use

try {
String myResult=root.busybox();  
if(myResult!=null&&myResult.length>0) {

    Busybox.setText(Html.fromHtml((myResult)));


}
else {

    Busybox.setText(Html.fromHtml((getString(R.string.no))));

    }
} 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Echo the content of a TextView?

From Dev

Php echo content into div

From Dev

echo display $content

From Dev

Php echo content into div

From Dev

TextView will not center its content

From Dev

TextView will not center its content

From Dev

Changing TextView content in fragment

From Dev

Showing the content of an array with printf (not echo)

From Dev

Redirecting the content of a file to the command "echo"

From Dev

How to echo the post's content

From Dev

Redirecting the content of a file to the command "echo"

From Dev

PHP echo content from <tags>

From Dev

Loop and echo specified JSON content

From Dev

Display parsed HTML content in a TextView

From Dev

Content in textview not showing (Android Studio)

From Dev

Gravity set, but TextView content not centered

From Dev

Display parsed HTML content in a TextView

From Dev

Get content of first 5 rows and echo them

From Dev

Echo content on the same line in jQuery Terminal

From Dev

Get content of first 5 rows and echo them

From Dev

How to echo <div> content when a checkbox is checked?

From Dev

Echo content on the same line in jQuery Terminal

From Dev

echo variable with content from command substitution

From Dev

Encode file content and echo it as one line

From Dev

use echo but do not print (too much content)

From Dev

echo -e content of file fetched using foreach

From Dev

Center content of TextView vertically & horizontally - LinearLayout

From Dev

textView height equal to content size without viewDidLayoutSubviews

From Dev

how to wrap the content of textview auto resize