Disable Home button by making my app a homeScreen App
up vote
1
down vote
favorite
I am trying to develop a lock application, I disabled the home button click but only in the phone where the button is hard clicked, but in the latest versions where there is no hard home button, the home button is not disabled. So After search I discovered that the only way to handle this problem is to make my app like the HomeScreen, I added this to my manifest:
<activity
android:name=".HomeActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:clearTaskOnLaunch="true"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:stateNotNeeded="true" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
When running this app, it shows me to choose between my app and android screen, when i choose my app, everytime i click the home button it opens my app!
My questions are:
1- Is that the only way to handle the home button in all android versions? by making my app a HomeScreen app?
2- Is there any other way to disable the home button only when my app is opened?
3- How Can I switch to TouchWiz default home screen programatically and remove my app as homeScreen when the lock is opened successfully ?
Thank you
android
add a comment |
up vote
1
down vote
favorite
I am trying to develop a lock application, I disabled the home button click but only in the phone where the button is hard clicked, but in the latest versions where there is no hard home button, the home button is not disabled. So After search I discovered that the only way to handle this problem is to make my app like the HomeScreen, I added this to my manifest:
<activity
android:name=".HomeActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:clearTaskOnLaunch="true"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:stateNotNeeded="true" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
When running this app, it shows me to choose between my app and android screen, when i choose my app, everytime i click the home button it opens my app!
My questions are:
1- Is that the only way to handle the home button in all android versions? by making my app a HomeScreen app?
2- Is there any other way to disable the home button only when my app is opened?
3- How Can I switch to TouchWiz default home screen programatically and remove my app as homeScreen when the lock is opened successfully ?
Thank you
android
do you have another activity to be started on application launch?
– gratien asimbahwe
yesterday
Yes I did, but the problem is that everytime you click on the home button it opens the application, and also there is no way to uninstall it from your phone!
– Mr.Geek
yesterday
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am trying to develop a lock application, I disabled the home button click but only in the phone where the button is hard clicked, but in the latest versions where there is no hard home button, the home button is not disabled. So After search I discovered that the only way to handle this problem is to make my app like the HomeScreen, I added this to my manifest:
<activity
android:name=".HomeActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:clearTaskOnLaunch="true"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:stateNotNeeded="true" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
When running this app, it shows me to choose between my app and android screen, when i choose my app, everytime i click the home button it opens my app!
My questions are:
1- Is that the only way to handle the home button in all android versions? by making my app a HomeScreen app?
2- Is there any other way to disable the home button only when my app is opened?
3- How Can I switch to TouchWiz default home screen programatically and remove my app as homeScreen when the lock is opened successfully ?
Thank you
android
I am trying to develop a lock application, I disabled the home button click but only in the phone where the button is hard clicked, but in the latest versions where there is no hard home button, the home button is not disabled. So After search I discovered that the only way to handle this problem is to make my app like the HomeScreen, I added this to my manifest:
<activity
android:name=".HomeActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".MainActivity"
android:clearTaskOnLaunch="true"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:stateNotNeeded="true" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
When running this app, it shows me to choose between my app and android screen, when i choose my app, everytime i click the home button it opens my app!
My questions are:
1- Is that the only way to handle the home button in all android versions? by making my app a HomeScreen app?
2- Is there any other way to disable the home button only when my app is opened?
3- How Can I switch to TouchWiz default home screen programatically and remove my app as homeScreen when the lock is opened successfully ?
Thank you
android
android
edited yesterday
asked yesterday
Mr.Geek
105
105
do you have another activity to be started on application launch?
– gratien asimbahwe
yesterday
Yes I did, but the problem is that everytime you click on the home button it opens the application, and also there is no way to uninstall it from your phone!
– Mr.Geek
yesterday
add a comment |
do you have another activity to be started on application launch?
– gratien asimbahwe
yesterday
Yes I did, but the problem is that everytime you click on the home button it opens the application, and also there is no way to uninstall it from your phone!
– Mr.Geek
yesterday
do you have another activity to be started on application launch?
– gratien asimbahwe
yesterday
do you have another activity to be started on application launch?
– gratien asimbahwe
yesterday
Yes I did, but the problem is that everytime you click on the home button it opens the application, and also there is no way to uninstall it from your phone!
– Mr.Geek
yesterday
Yes I did, but the problem is that everytime you click on the home button it opens the application, and also there is no way to uninstall it from your phone!
– Mr.Geek
yesterday
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Try removing the other activity and proceed this way:
<activity android:name=".MainActivity"
android:clearTaskOnLaunch="true"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:stateNotNeeded="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Every time someone hits the home button, it will be opening your activity which is a home screen and this time it will not have to open the home activity first.
EDIT:
If then you want to comeback to your default launcher after home button pressed, you can override these methods:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
if(keyCode == KeyEvent.KEYCODE_HOME)
Intent intent=null;
final PackageManager packageManager=getPackageManager();
for(final ResolveInfo resolveInfo:packageManager.queryIntentActivities(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), PackageManager.MATCH_DEFAULT_ONLY))
if(!getPackageName().equals(resolveInfo.activityInfo.packageName)) //if this activity is not in our activity (in other words, it's another default home screen)
intent=packageManager.getLaunchIntentForPackage(resolveInfo.activityInfo.packageName));
startActivity(intent);
break;
if(keyCode==KeyEvent.KEYCODE_BACK)
finish();
return false;
Yes, but my application is only a phone lock app, that means when the user enters the code successfuly, i want the default home screen to be the normal one : TouchWiz and not my app! is there any way to do it programatically?
– Mr.Geek
yesterday
I have edited my answer, please check
– gratien asimbahwe
yesterday
It's exactly what i needed! what is the code to launch default launcher or to open the chooser of home screens?
– Mr.Geek
yesterday
I have updated my answer, please check. if it works come back and mention it works to help future readers.
– gratien asimbahwe
yesterday
App crashes! it shows me this exception: java.lang.IllegalArgumentException: Window type can not be changed after the window is added.
– Mr.Geek
yesterday
|
show 4 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Try removing the other activity and proceed this way:
<activity android:name=".MainActivity"
android:clearTaskOnLaunch="true"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:stateNotNeeded="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Every time someone hits the home button, it will be opening your activity which is a home screen and this time it will not have to open the home activity first.
EDIT:
If then you want to comeback to your default launcher after home button pressed, you can override these methods:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
if(keyCode == KeyEvent.KEYCODE_HOME)
Intent intent=null;
final PackageManager packageManager=getPackageManager();
for(final ResolveInfo resolveInfo:packageManager.queryIntentActivities(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), PackageManager.MATCH_DEFAULT_ONLY))
if(!getPackageName().equals(resolveInfo.activityInfo.packageName)) //if this activity is not in our activity (in other words, it's another default home screen)
intent=packageManager.getLaunchIntentForPackage(resolveInfo.activityInfo.packageName));
startActivity(intent);
break;
if(keyCode==KeyEvent.KEYCODE_BACK)
finish();
return false;
Yes, but my application is only a phone lock app, that means when the user enters the code successfuly, i want the default home screen to be the normal one : TouchWiz and not my app! is there any way to do it programatically?
– Mr.Geek
yesterday
I have edited my answer, please check
– gratien asimbahwe
yesterday
It's exactly what i needed! what is the code to launch default launcher or to open the chooser of home screens?
– Mr.Geek
yesterday
I have updated my answer, please check. if it works come back and mention it works to help future readers.
– gratien asimbahwe
yesterday
App crashes! it shows me this exception: java.lang.IllegalArgumentException: Window type can not be changed after the window is added.
– Mr.Geek
yesterday
|
show 4 more comments
up vote
0
down vote
Try removing the other activity and proceed this way:
<activity android:name=".MainActivity"
android:clearTaskOnLaunch="true"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:stateNotNeeded="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Every time someone hits the home button, it will be opening your activity which is a home screen and this time it will not have to open the home activity first.
EDIT:
If then you want to comeback to your default launcher after home button pressed, you can override these methods:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
if(keyCode == KeyEvent.KEYCODE_HOME)
Intent intent=null;
final PackageManager packageManager=getPackageManager();
for(final ResolveInfo resolveInfo:packageManager.queryIntentActivities(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), PackageManager.MATCH_DEFAULT_ONLY))
if(!getPackageName().equals(resolveInfo.activityInfo.packageName)) //if this activity is not in our activity (in other words, it's another default home screen)
intent=packageManager.getLaunchIntentForPackage(resolveInfo.activityInfo.packageName));
startActivity(intent);
break;
if(keyCode==KeyEvent.KEYCODE_BACK)
finish();
return false;
Yes, but my application is only a phone lock app, that means when the user enters the code successfuly, i want the default home screen to be the normal one : TouchWiz and not my app! is there any way to do it programatically?
– Mr.Geek
yesterday
I have edited my answer, please check
– gratien asimbahwe
yesterday
It's exactly what i needed! what is the code to launch default launcher or to open the chooser of home screens?
– Mr.Geek
yesterday
I have updated my answer, please check. if it works come back and mention it works to help future readers.
– gratien asimbahwe
yesterday
App crashes! it shows me this exception: java.lang.IllegalArgumentException: Window type can not be changed after the window is added.
– Mr.Geek
yesterday
|
show 4 more comments
up vote
0
down vote
up vote
0
down vote
Try removing the other activity and proceed this way:
<activity android:name=".MainActivity"
android:clearTaskOnLaunch="true"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:stateNotNeeded="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Every time someone hits the home button, it will be opening your activity which is a home screen and this time it will not have to open the home activity first.
EDIT:
If then you want to comeback to your default launcher after home button pressed, you can override these methods:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
if(keyCode == KeyEvent.KEYCODE_HOME)
Intent intent=null;
final PackageManager packageManager=getPackageManager();
for(final ResolveInfo resolveInfo:packageManager.queryIntentActivities(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), PackageManager.MATCH_DEFAULT_ONLY))
if(!getPackageName().equals(resolveInfo.activityInfo.packageName)) //if this activity is not in our activity (in other words, it's another default home screen)
intent=packageManager.getLaunchIntentForPackage(resolveInfo.activityInfo.packageName));
startActivity(intent);
break;
if(keyCode==KeyEvent.KEYCODE_BACK)
finish();
return false;
Try removing the other activity and proceed this way:
<activity android:name=".MainActivity"
android:clearTaskOnLaunch="true"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:stateNotNeeded="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Every time someone hits the home button, it will be opening your activity which is a home screen and this time it will not have to open the home activity first.
EDIT:
If then you want to comeback to your default launcher after home button pressed, you can override these methods:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
if(keyCode == KeyEvent.KEYCODE_HOME)
Intent intent=null;
final PackageManager packageManager=getPackageManager();
for(final ResolveInfo resolveInfo:packageManager.queryIntentActivities(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), PackageManager.MATCH_DEFAULT_ONLY))
if(!getPackageName().equals(resolveInfo.activityInfo.packageName)) //if this activity is not in our activity (in other words, it's another default home screen)
intent=packageManager.getLaunchIntentForPackage(resolveInfo.activityInfo.packageName));
startActivity(intent);
break;
if(keyCode==KeyEvent.KEYCODE_BACK)
finish();
return false;
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
if(keyCode == KeyEvent.KEYCODE_HOME)
Intent intent=null;
final PackageManager packageManager=getPackageManager();
for(final ResolveInfo resolveInfo:packageManager.queryIntentActivities(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), PackageManager.MATCH_DEFAULT_ONLY))
if(!getPackageName().equals(resolveInfo.activityInfo.packageName)) //if this activity is not in our activity (in other words, it's another default home screen)
intent=packageManager.getLaunchIntentForPackage(resolveInfo.activityInfo.packageName));
startActivity(intent);
break;
if(keyCode==KeyEvent.KEYCODE_BACK)
finish();
return false;
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
if(keyCode == KeyEvent.KEYCODE_HOME)
Intent intent=null;
final PackageManager packageManager=getPackageManager();
for(final ResolveInfo resolveInfo:packageManager.queryIntentActivities(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME), PackageManager.MATCH_DEFAULT_ONLY))
if(!getPackageName().equals(resolveInfo.activityInfo.packageName)) //if this activity is not in our activity (in other words, it's another default home screen)
intent=packageManager.getLaunchIntentForPackage(resolveInfo.activityInfo.packageName));
startActivity(intent);
break;
if(keyCode==KeyEvent.KEYCODE_BACK)
finish();
return false;
edited yesterday
answered yesterday
gratien asimbahwe
6671421
6671421
Yes, but my application is only a phone lock app, that means when the user enters the code successfuly, i want the default home screen to be the normal one : TouchWiz and not my app! is there any way to do it programatically?
– Mr.Geek
yesterday
I have edited my answer, please check
– gratien asimbahwe
yesterday
It's exactly what i needed! what is the code to launch default launcher or to open the chooser of home screens?
– Mr.Geek
yesterday
I have updated my answer, please check. if it works come back and mention it works to help future readers.
– gratien asimbahwe
yesterday
App crashes! it shows me this exception: java.lang.IllegalArgumentException: Window type can not be changed after the window is added.
– Mr.Geek
yesterday
|
show 4 more comments
Yes, but my application is only a phone lock app, that means when the user enters the code successfuly, i want the default home screen to be the normal one : TouchWiz and not my app! is there any way to do it programatically?
– Mr.Geek
yesterday
I have edited my answer, please check
– gratien asimbahwe
yesterday
It's exactly what i needed! what is the code to launch default launcher or to open the chooser of home screens?
– Mr.Geek
yesterday
I have updated my answer, please check. if it works come back and mention it works to help future readers.
– gratien asimbahwe
yesterday
App crashes! it shows me this exception: java.lang.IllegalArgumentException: Window type can not be changed after the window is added.
– Mr.Geek
yesterday
Yes, but my application is only a phone lock app, that means when the user enters the code successfuly, i want the default home screen to be the normal one : TouchWiz and not my app! is there any way to do it programatically?
– Mr.Geek
yesterday
Yes, but my application is only a phone lock app, that means when the user enters the code successfuly, i want the default home screen to be the normal one : TouchWiz and not my app! is there any way to do it programatically?
– Mr.Geek
yesterday
I have edited my answer, please check
– gratien asimbahwe
yesterday
I have edited my answer, please check
– gratien asimbahwe
yesterday
It's exactly what i needed! what is the code to launch default launcher or to open the chooser of home screens?
– Mr.Geek
yesterday
It's exactly what i needed! what is the code to launch default launcher or to open the chooser of home screens?
– Mr.Geek
yesterday
I have updated my answer, please check. if it works come back and mention it works to help future readers.
– gratien asimbahwe
yesterday
I have updated my answer, please check. if it works come back and mention it works to help future readers.
– gratien asimbahwe
yesterday
App crashes! it shows me this exception: java.lang.IllegalArgumentException: Window type can not be changed after the window is added.
– Mr.Geek
yesterday
App crashes! it shows me this exception: java.lang.IllegalArgumentException: Window type can not be changed after the window is added.
– Mr.Geek
yesterday
|
show 4 more comments
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53224482%2fdisable-home-button-by-making-my-app-a-homescreen-app%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
do you have another activity to be started on application launch?
– gratien asimbahwe
yesterday
Yes I did, but the problem is that everytime you click on the home button it opens the application, and also there is no way to uninstall it from your phone!
– Mr.Geek
yesterday