I am developing an App that need to have an option or should i say a link when user gets the properties or menu list from call logs i.e when a user long press on an entry in call logs of phone. I have trying for hours now but not getting any useful information in internet. Please help.
Adding options to context menus of other apps is really not possible. For your example specifically if you see the Contacts app over there is made by Samsung and this may vary for other OEMs and it is totally up to them how they decide to design their user interactions within their apps.
Another point to this discussion can be related to apps like WhatsApp whose options (like calling) appear in the Phone app itself. This is because it has registered itself as having that ability in its <intent-filter> and the Phone app itself shows all apps with that ability. However, you cannot decide what options the default Phone app shows.
A previous developer for my company created an application that serves as the launcher for multiple types of android phones. These phones are given out to employees to use for business purposes so the application limits access on the phone to applications that are allowed by us.
The application works fine on all versions of Android up until Lollipop. On phones that have lollipop on them a user is able to access the settings from the notification bar (something that the app blocks on previous versions of Android) and also by long pressing on the home button, the google app is launched (that was also blocked by the application on phones that have versions less than lollipop. Package name for this application is com.google.android.googlequicksearchbox).
I have been researching this for a couple of days and I cannot figure out what has changed with lollipop to make the app stop working. I tried it on a motorolla turbo 2 and a galaxy s5 that are running lollipop and the problem exists on both.
I tried multiple solutions:
Override or disable settings menu
this link does not work for because it would basically run my application every time the user tries to access settings, which is a feature that we still give as administrative privilege to some people
Detect home button press in android
I tried this link, as well as other links to override the functionality of the long press on the Home button but I couldn't capture the press on the Home button.
Question:
Q1:
Is there a way to disable access to settings from notification bar, like hide the settings icon from the notification bar or even disable notification bar completely?
Q2:
Is there a way to intercept long presses on the Home Button or to change what the long press on the home button does?
Any help would be much appreciated. Thank you
Problem Fixed.
The application logic was to get the foreground application package using
getRunningTasks(int maxNum) which does not work after the lollipop update, so I added the code from the answer to this question: How to get recent tasks on Android "L"?
Thank you Marcin Orlowski .
I am working on an application in which user should be able to use only one application,
he should not be able to switch application using HOME button,
the app. should be closed only when user presses the close button..
I have managed to override return button, don't know how to disable HOME button.
This is not possible to disable the Home Button in android When application is in the background because it might some application always disable the home button if it's possible. So this is the reason developer can't disable the home button when app in background. But In the Activity, you can intercept the home button.
In Activity you can disable the Home key in android. It work till Android 3.x only.
#Override
public void onAttachedToWindow() {
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
TGMCians is right.
Android will not let an activity and its services run completely alone on your device.
Using Override you can capture button clicks (home, back and menu) when your activity is in the foreground. If an activity/service has full control from the background you would not be able to switch for an incoming sms, e-mails, phone calls, etc either.
Personally I think its dangerous to override the home and back button together, if the activity hangs at some point, you can not get out of the app unless you restart the phone.
Personally, I do override the back key for exit, or return to main screen events, but leave the home button alone.
This is not possible using code at all on iOS, ever.
One usage of HOME button is for emergency situation.
Any house, apartment ... they all have an emergency method, like emergency door (exit), glass breaker (axe, bat ...); it saves life.
Similarly, on Android/iOS phone, HOME button saves users' lives (well, kind of). If HOME button is dead, the phone is considered dead as well as required an instant reboot for refresh. The button was designed for such a purpose, so that developers can't messed-up with everything.
Personally, I'm kinda of being thankful for Android/iOS framework team and whoever thought of this situation on HOME button. It saves my development so many times. I suggest you should think and consider the worst case possible if HOME button is not working in your app; for example, app fails to function as normal, HOME is disabled, so how to back to HOME screen, how to switch to other apps?...
The code provided by TGMCians is not working on 4.0+.
In case, you are working on Android framework, such as building ROMs, building frameworks for manufacturers, ... grep the source code with KEY_HOME and trace inner-depth to find how it works and disable it.
actually, it is possible to block the home button using the next methods:
use of security holes, at least on old android versions. this is done on some locker apps. i think some still work even on newer android versions, but it's a risk and it might be buggy on some devices. i know that "widgetLocker" and "Picture Password Lockscreen" try out those holes. i'm not sure how well they work now with them. best solution of becoming a lockscreen is #2 .
make your app a launcher app, which will handle the home button (user must confirm it of course). an example of such an app is "MagicLocker" , and in fact any launcher app...
using a rooted device. i have no idea how to do it, but i think it's very possible.
not quite a blocking method, but you could have your app full screen and on top (using the TYPE_SYSTEM_ALERT window layout type) , so home button won't be captured, but the user won't see what's going on behind your app. the downside is that any other button won't be captured by your app, since it's not really on the foreground.
I'm developing a Android application, and I would like that when it first starts it set itself as default action for Home button.
Currently this option is given to the user by the Android system only when he first press the Home button after running my app.
User don't want to click on check box as "Use by default for this action" it should be set by default my apps.
Thanks in advance.
This is not possible, and it is a good thing too.
Android allows users to choose their own defaults to prevent malicious apps from making themselves the default app to deal with an action, and hence protecting the user's data and device. If an app could set itself as the default homescreen or browser or call app etc. then it could steal the user's personal data and also potentially spoil or deny access to the device itself.
Due to the above reasons, this is not possible why the Android SDK, and I sincerely doubt that an unofficial means to do this exists.
I have looked everywhere for something related to this. I want to launch a shortcut, based on the shortcuts installed on a device.
A simple way of putting this is my user selects one of his shortcuts through my application. When the user initiates the shortcut through my app, it will perform the exact same thing as if he/she is on the home screen and selects the shortcut.
I can do this individually with the system shortcuts, but I want to have more flexibility for other shortcuts installed on the device.
So basically, I need to figure out how to bring up the shortcut picker (the same list that appears by long pressing a home screen and selecting shortcuts), get the intent to launch that shortcut and store that within my application data for use later. I don't want to actually initiate the shortcut when the user selects it, I just want to remember it for later.
Any help with this would be greatly appreciated :)
I think you are looking for this: https://developer.android.com/reference/android/content/Intent.html#ACTION_CREATE_SHORTCUT