I\'m writing an industry application which will be used by traffic wardens to register offences through my program using forms.
The app is using a webview so it is just
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
getWindow().addFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
@Override
public void onBackPressed() {
return;
}
@Override
public void onAttachedToWindow()
{
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
The idea is that I am able to make the app the default home app so if the user presses the home button it launches my app and does not exit. How can I accomplish that?
There is a sample Home application in your Android SDK. Mirror its manifest entry, notably putting the HOME
category in the activity's <intent-filter>
.
The first time the, er, traffic warden taps HOME after installing your app, a chooser will appear for which home app to run. Checking the checkbox and tapping your app will then mean the HOME button will run your app forevermore.
Beyond creating a custom home app, though, there is no way to intercept the HOME button except through firmware modifications.