单击“Check For BusyBox”按钮时没有任何反应

时间:2014-03-06 17:44:39

标签: java android button busybox roottools

我创建了一个使用RootTools检查root的应用程序。现在,我添加了一个检查BusyBox可用性的选项。当我点击“Check For BusyBox”时,没有任何反应,尽管“Check For Root”工作正常。我不明白为什么会这样。请帮忙!

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

                    }

                }
            });

        }

    });
}}

1 个答案:

答案 0 :(得分:0)

有关BusyBox按钮的所有代码(包括其OnClickListener的定义)都写在Root按钮OnClickListener代码中。移动代码,它应该适合你。