Is there anyway to capture when the user clicks on the application icon in the built in search dialog? Please note I am NOT referring to a custom dialog but to android built in search dialog.
Nope, there is no way to make the SearchDialog's app icon clickable.
But just for fun, let's assume there existed some hacky workaround that would get the job done. Cool, we have got the desired behavior... but now we have two issues:
The behavior of the SearchDialog is not consistent with other Android devices. This lessens the user experience since users expect search interfaces to work the same on all Android devices.
Your app now makes use of the internal APIs, which may or may not remain consistent when new SDKs are released. For all you know, the Android team could change the app icon's id from #+id/search_app_icon to #+id/search_home_icon. Your hack depends on the internal APIs... so such a change will cause newer devices running your app to crash (as any runtime search for search_app_icon will return null).
Further, companies like Samsung and HTC are free to alter the internal APIs before they release their new devices to the public. The next Samsung Galaxy could potentially completely re-implement the SearchDialog class, update its UI/theme, etc... you can never know for sure.
So basically, you can't... and you shouldn't make an attempt to do so.
Just because I'm bored, here's the source code that led me to my answer:
Check out the source code for SearchManager.java, and notice that the SearchManager keeps the SearchDialog as a private instance variable mSearchDialog.
Check out the source code for SearchDialog.java, and notice that the SearchDialog references the app icon as the private instance variable mAppIcon. Also notice that the SearchDialog initializes the variable through a call to findViewById, as seen here.
Check out the source code for search_bar.xml and notice that the ImageView is not set to clickable by default. Since there are no (methods in the public SDK that alter the behavior of this View, there is no reliable way to make it clickable.
I'm sure it's impossible to do this using the Android's public SDK.
I think the only solution is write your own custom dialog, but I'm affraid that with the built in dialog you can't accomplish this.
Related
my problem is that:
I want to make a login service in my application and depending on which user logs in, go to a different NavDrawer activity. In Android Studio when you create the NavDrawer activity that comes by default, it generates one perfectly. But when I want to generate a different one, having the same name doesn't create anything.
The only way I have found is by refactoring everything generated by the Android Studio wizard and changing all the names of the layouts.
I would like to know if there is an easier way to create another NavDrawer without having to refactor so much and without so many errors.
Thank you!
NavDrawers Generated
Conceptual Scheme
Its Solved, you only need to make an instance of one of these nav drawers and then extend that to another one.
I am completely new to Andoid Studio, Java, and app development in general.
With that, in order to learn, I downloaded Android Studio version 2.3. And, for my first project, I imported the accelerometer example from the sensors library. I opened it, poked around, didn't change/save anything, and ran/installed the app on my phone (simply clicking the RUN button from the SDK), and it worked fine ... I see the metal balls rolling across my screen.
NEXT, I figured I would make a small change to the project and see what I have to do to rebuild/remake the app, since I see 'make project', 'make app', 'rebuild', 'build apk', and 'synchronize' ... still not sure what all those do exactly.
So, my simple change was in the app/res/layout/main.xml file, and all I changed was
from:
android:background="#drawable/wood"
to:
android:background="#drawable/ball"
After this change, I went through every possible make, build, clean sequence I could think of, including the synchronize options within the different files. I've even disabled the instant run feature, uninstalled the app from my phone, restarted my phone, and restarted Android SDK. I even found a checkbox to "skip installation if APK has not changed" in the RUN/DEBUG configuration window.
What am I missing? Every time I RUN APP, it's as if no changes were made ... I get the same "wood" background from the original main.xml file.
Here is a link to the repo: https://github.com/googlesamples/android-AccelerometerPlay/
I checked the code and if you take a look to the AccelerometerPlayActivity you can see that the background of the view that acts as the activity content (SimulationView) is being set on this piece of code (in the onCreate method):
// instantiate our simulation view and set it as the activity's content
mSimulationView = new SimulationView(this);
mSimulationView.setBackgroundResource(R.drawable.wood);
setContentView(mSimulationView);
So, that's where you have to make your changes.
I'm trying to remove the Home button and the Multithread button. The idea is to remove it completely from the running application, better if we can remove it completely from every application on the tablet we are working with. Using full-screen is not something that we want, since the user shouldn't be able to exit the full screen mode, even if he wants it (it's a custom commercial app, it's the desired behaviour for multiple reasons).
This is the result on a Nexus 10. We accomplished that by taking the SystemUI sources and changing them before compiling the CyanogenMod.
Unfortunately we have to replicate that in an Asus ZenPad 10, that has no CyanogenMod available. We have a version that allows us to create system applications, but change every application into a system application is not something that we want.
We have found in this link: http://developer.oesf.biz/em/developer/reference/eggplant/constant-values.html#android.view.View.STATUS_BAR_DISABLE_HOME
That there are flags for disabling the home button and the navigation button, but they are usable only with system applications.
We have tried to get the SystemUI.apk already compiled in the tablet, decompile it and change it. The problem is that or we have useless smali files or with have only res/ and AndroidManifest.xml files (Asus changed the SystemUI.apk into two apks of it own).
So... we are a little desperate here ahah. Looking for hints / ideas to try to remove that buttons. Better without recompiling or doing some strange thing.
This is possible using a combination of permissions like Immersive Full-Screen Mode combined with the SYSTEM_UI_FLAG_HIDE_NAVIGATION and SYSTEM_UI_FLAG_FULLSCREEN flags. These flags hide the navigation and status bar, now that you have a blank screen put a linear laoyout at the bottom of the screen with only the back icon visible, just to create the effect of what you want. ALSO note that it is important to understand that once the user swipes upwards the normal navigation bar will be visible(not sure if it can be handeled through intercept touch event).
Alternatively you can try out this solution mentioned here also
How to disable Home and other system buttons in Android?
also refer this github project(works if there is only a hardware navigation buttons)
https://github.com/shaobin0604/Android-HomeKey-Locker
Last But not the least There is an answer by commsware that throws more light on this subject might come in handy.
Not able disable Home button on specific android devices
Try Android for work APIs and refer here.Using this apis you can get full control of the device and disable whatever you want.The device can be used only for single app.
Corporate-owned, single-use (COSU) is a subset of the corp-liable scenario for shared or special-use devices. Unlike corp-liable devices that are associated with individual employees, COSU devices are associated with particular business functions. For example, a COSU device might be used as a kiosk.
You can also try to integrate custom MDM(Mobile device management) solution provided by OEMS/MDM vendors/MDM partners like Samsung, HTC, Airwatch etc. This work on devices prior to lollipop too and provide more APIs to control the device than provided by default android solution.
I know Samsung MDM/Knox solution is good and it has APIs to control each and every part of the device.Refer- http://www.samsung.com/levant/business/solutions-services/mobile-solutions/security/mobile-device-management.They have Kiosk mode which is similar to COSU.
You will ask permission to the user. In this car this is yourself. Be careful since you will have to implement a way back out of the application.
Reference: disable home
Or you just could buy a case to stick it around, so the buttons won't be visible...
use immerse mode, use this code in onResume() so that everytime you get back to your activity its ran and they are hid
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
Of course, you can't REMOVE any System Buttons like Power, Volume +/-, Home, Back or Menu. You can only hide or show Home, Back or Menu only when they are virtual(opposite to Solid Buttons).
Meanwhile, hiding the navigation bar is limited. It only can be completed on Android 4.0 and higher. So, if you want to do this, you need to use the SYSTEM_UI_FLAG_HIDE_NAVIGATION flag. This snippet hides both the navigation bar and the status bar:
View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
And, if you want to set your application's content to appear behind the navigation bar, you need the SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION flag. You may also need to use SYSTEM_UI_FLAG_LAYOUT_STABLE to help your app maintain a stable layout.
i have tried the same for a long period of time and searched a lot
but as you know the HOME button is the only way for user to get out from
any app in any situation. its very risky to block that and google will not allow it.
One thing you can do is set your application as a launcher application then u can receive keyevent Home
Basically I'm pretty new to android development but so far I've been able to fix every issue/bug I've had except this one (I've seen way worse, but for some reason this little bug takes all my time..).
Just for contact, I'm doing an application that loads local and external xml file and displays the content, fetch xml files from a server and save them locally, etc.
The issue I'm running into is the following; on older android phones (on 4.4 there is no issue, on 4.0 there is) when the application loads, I have a loading spinner icon in my action bar while the only place I use one is in another layout that is not referenced in my main activity. I figured maybe it's because I didn't initiate my menu correctly or something, but everything seems fine (and works on newer versions). I have a searchview that is working fine, a settings menu that is also fine, but for some reason there is always a spinning icon next to those elements.
I can edit this and add my layout/code if needed.
Thanks!
maybe put setProgressBarIndeterminateVisibility(false) in Activitys onCreate (check docs)
I have read around a bit on this and I can't seem to find what I am looking for. Basically, I want to create an app that switches between launchers at user defined events (for example shaking the screen or entering a code).
I have looked at Start Launcher Selection Programatically so I am fairly certain that it is possible to start the launcher selection tool, I just don't know if there is a way to change between launchers automatically without requiring the selection tool.
The idea is that, since I am practicing with custom launchers I often times leave one running on my phone to test its functionality. However, this can lead to unexpected issues I would like to quickly get out of by switching over to the default launcher (things like I need to quickly make a call and my "Make a Call" button isn't acting like I had planned).
Is there a better way to go about this if automatic launcher switches is an impossible/bad way to go?
I just don't know if there is a way to change between launchers automatically without requiring the selection tool
Fortunately, this is not possible, for obvious security reasons. Malware authors would love the ability to replace the user's home screen with one that did not offer a way to get back into the regular one.
The user has to be involved in the decision over what home screen implementation to use.