disable the Home Button and Back Button"
Posted
by
michael
on Stack Overflow
See other posts from Stack Overflow
or by michael
Published on 2013-10-31T09:39:32Z
Indexed on
2013/10/31
9:54 UTC
Read the original article
Hit count: 139
i want way to disable the Home Button & Back Button when click on checkbox in application ,
my application on version 4.2.2
i have code but not work when click on checkbox work stop to application
public void HardButtonOnClick(View v)
{
boolean checked1 = ((CheckBox) v).isChecked();
if(checked1)
{
SQLiteDatabase db;
db = openOrCreateDatabase("Saftey.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
db.setVersion(1);
db.setLocale(Locale.getDefault());
db.setLockingEnabled(true);
ContentValues values = new ContentValues();
values.put("hardBtn", "YES");
db.update("Setting", values, "id = ?", new String[] { "1" });
Toast.makeText(this, "Hard Button Locked", Toast.LENGTH_LONG).show();
//SharedPreferences pref = getSharedPreferences("pref",0);
//SharedPreferences.Editor edit = pref.edit();
//edit.putString("hard","yes");
//edit.commit();
/* String Lock="yes" ;
Bundle bundle = new Bundle();
bundle.putString("key", Lock);
Intent a = new Intent(Change_setting.this, ChildMode.class);
a.putExtras(bundle);
startActivity(a);*/
super.onAttachedToWindow();
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
isLock = true;
}
else
{
SQLiteDatabase db;
db = openOrCreateDatabase("Saftey.db", SQLiteDatabase.CREATE_IF_NECESSARY, null);
db.setVersion(1);
db.setLocale(Locale.getDefault());
db.setLockingEnabled(true);
ContentValues values = new ContentValues();
values.put("hardBtn", "NO");
db.update("Setting", values, "id = ?", new String[] { "1" });
//SharedPreferences pref = getSharedPreferences("pref",0);
//SharedPreferences.Editor edit = pref.edit();
//edit.putString("hard","no");
//edit.commit();
Toast.makeText(this, "Hard Button Un-Locked", Toast.LENGTH_LONG).show();
isLock = false;
}
}
how can work it??
© Stack Overflow or respective owner