Question

I made an application that checks for root using RootTools. Now, I added an option to check for BusyBox availability. When I click on "Check For BusyBox", nothing happens, though the "Check For Root" is working perfectly. I don't understand why is it happening. Please help!

package com.maverick.checkforroot;

import com.stericson.RootTools.RootTools;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    TextView Manufacturer = (TextView) findViewById(R.id.Manufacturer);
    String Manu = android.os.Build.MANUFACTURER;;
    Manufacturer.setText(Manu);

    TextView tv1 = (TextView) findViewById(R.id.tv1);
    String Model = android.os.Build.MODEL;
    tv1.setText(Model);

    TextView Product = (TextView) findViewById(R.id.Product);
    String Pro = android.os.Build.PRODUCT;;
    Product.setText(Pro);

    Button Root = (Button) findViewById(R.id.Root);
    Root.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            if (RootTools.isAccessGiven()) {

                    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                    builder.setIcon(R.drawable.ic_launcher);
                    builder.setTitle("Congratulations!");
                    builder.setMessage("You Have Root Access!");

                    builder.setPositiveButton("OKAY", new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.cancel();
                        }
                    });

                    AlertDialog dialog = builder.create();
                    dialog.show();
                }

            else  {
                 AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                    builder.setIcon(R.drawable.ic_launcher);
                    builder.setTitle("Oops!");
                    builder.setMessage("No Root Access!");
                    builder.setPositiveButton("OKAY", new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                            dialog.cancel();
                        }
                    });

                    AlertDialog dialog = builder.create();
                    dialog.show();  
            }
            Button BusyBox = (Button) findViewById(R.id.BusyBox);
            BusyBox.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View arg0) {

                    if (RootTools.isBusyboxAvailable()) {
                        Toast.makeText(MainActivity.this,"No BusyBox!", Toast.LENGTH_LONG).show();

                    } else {
                        Toast.makeText(MainActivity.this,"BusyBox Is Available!", Toast.LENGTH_LONG).show();

                    }

                }
            });

        }

    });
}}
Was it helpful?

Solution

All the code concerning the BusyBox button (inclusive the definition of its OnClickListener) is written inside the Root buttons OnClickListener code. Move the code and it should work for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top