I have a problem with disable application through package manager function disable/enable. In android terminal is all corect, but in this application not. However " Runtime.getRuntime().exec("su"); " functioning normally and carrying out his activity.
public class AppInfoAdapter extends BaseAdapter {
private Context aContext;
private List<ApplicationInfo> aListAppInfo;
private PackageManager aPackManager;
private CheckBox chAppStat ;
public AppInfoAdapter(Context c, List<ApplicationInfo> list, PackageManager pm) {
aContext = c;
aListAppInfo = list;
aPackManager = pm;
}
@Override
public int getCount() {
return aListAppInfo.size();
}
@Override
public Object getItem(int position) {
return aListAppInfo.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ApplicationInfo entry = aListAppInfo.get(position);
//positon = position;
View v = convertView; // convertView
// recyklovace
if(v == null) {
LayoutInflater inflater = LayoutInflater.from(aContext);
v = inflater.inflate(R.layout.layout_appinfo, null);
}
// nahrat layout
ImageView ivAppIcon = (ImageView)v.findViewById(R.id.ivIcon);
TextView tvAppName = (TextView)v.findViewById(R.id.tvName);
TextView tvPkgName = (TextView)v.findViewById(R.id.tvPack);
chAppStat = (CheckBox)v.findViewById(R.id.chBox);
//text = entry.packageName;
chAppStat.setTag(entry.packageName);
chAppStat.setOnCheckedChangeListener(aListener);
// privest na vystup
ivAppIcon.setImageDrawable(entry.loadIcon(aPackManager));
tvAppName.setText(entry.loadLabel(aPackManager));
tvPkgName.setText(entry.packageName);
// navrat view
return v;
}
OnCheckedChangeListener aListener = new CompoundButton.OnCheckedChangeListener () {
public void onCheckedChanged( CompoundButton buttonView, boolean isChecked) {
if(isChecked = true){
try {
Runtime.getRuntime().exec("su");
Runtime.getRuntime().exec("pm disable "+ buttonView.getTag());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
try {
Runtime.getRuntime().exec("pm enable "+ buttonView.getTag());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
};
}
recapitulation: problem is package manager function disable/enable in the application. BUT in terminal is correct "pm disable some.name.package"
try {
Runtime.getRuntime().exec("su");
Runtime.getRuntime().exec("pm disable "+ buttonView.getTag());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}