在mainActivity中:
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private TextView result;
private Context mContext;
private ComponentName cn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mContext = this;
cn = this.getComponentName();
result = (TextView) findViewById(R.id.result);
findViewById(R.id.app).setOnClickListener(this);
findViewById(R.id.act).setOnClickListener(this);
findViewById(R.id.rec).setOnClickListener(this);
findViewById(R.id.ser).setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.app:
try {
ApplicationInfo appInfo = mContext.getPackageManager().get