在下面的代码中,我尝试使用 roottools 检查 root 访问权限。没有任何语法错误,但是每当我单击“检查根访问”按钮时,都会收到“应用程序已意外停止”消息。请帮忙。
package com.maverick.checkforroot;
import com.stericson.RootTools.RootTools;
import android.app.Activity;
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()) {
Toast.makeText(MainActivity.this,"Root Access!", Toast.LENGTH_LONG).show();
}
else {
Toast.makeText(MainActivity.this,"No Root Access!", Toast.LENGTH_LONG).show();
}
}
});
}}