简体   繁体   中英

Nothing happens when I click on the “Check For BusyBox” button

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();

                    }

                }
            });

        }

    });
}}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM