Android: Adding Activity to the menu on the homescreen - android

I'm trying to add my Android activity to the menu on the homescreen (the one with: add, wallpaper, settings, search, notifications).
I suspect this is done from the AndroidManifest.xml, but I can't figure out how.
Am I looking at the right place? And if so, what am I missing?

You can't add your application there. That's controlled by the "home activity" which you don't have control over (for good reasons, otherwise anyone could add anything there).

Related

Android launchMode and "infinite" SettingsActivities

I have huge problems, to understand the launchMode of Android apps or, let's say, I struggle to understand, why singleTask isn't the "wanted" or desired default option.
I can't imagine actually any advantage of having or wanting to have more than one active running activity (GUI) instance. It would make sense, of course, if the activity was a sub GUI, where you maybe want to have multiple "tabs", for example in a web browser, file manager, etc. But those are very specific examples, and for a normal app GUI, does it make sense to allow multiple instances of the same GUI frame? On a desktop, there is always one GUI instance, never multiple. One settings instance, one sub settings, and so on. And if you closed the window, you always go back to the one instance of the previous frame.
I noticed this actually really fast, after I implemented a SettingsActivity (AppCompatPreferenceActivity) via the default activity template of Android Studio. The problem now was that my app created "infinite" sub setting menus if I went forth/back/forth/back in the settings activity. When I was now pressing the back button, I ran into the this problem:
submenu1 > menu > submenu1 > menu > submenu2 > menu > submenu2 > menu... > mainacitivity > app closing
Of course, although this can't be the desired behavior, still it's given as default behavior by Android Studio, and as I understand, is the normal behavior for launchMode=standard (or not putting it in the manifest file anyway).
For a SettingsActivity, it just doesn't make sense in my understanding to have more than one running instance, and if the user pressed the back button in a sub menu, it should always bring him back to the menu before, and if he's in main menu, into the activity before that.
So how can I change this? or is my whole understanding just wrong? Should a SettingsActivity be set as launchMode=singleTask? Or how did I get into this infinite loop of back and forth by pressing the back button, if I went into sub menus "too often" before?
I actually read somewhere before, that you should avoid using launchMode=singleTask, but I don't know why. In my understanding a singleTask would just make more sense, for mostly every situation. How would it make sense to allow multiple instances of any GUI frame...
Hope this isn't a stupid question. I tried to find a satisfying answer to this, but I couldn't find an explanation really to my questions.

A second home screen button to open a secondary activity?

I made an image viewer MyImageViewer, and I had to build a filemanager for it, called MyFileManager, as a class. I open MyFileManager from MyImageViewer through Intents perfectly.
It turns out that now I like MyFileManager more than the actual file manager that came with my Android (that is tooooo slow and tooooo limited). So I want to add a second launcher button to the Home Screen for MyFileManager class, besides the one I already have for MyImageViewer.
Is there an easy way to do this, besides using widgets? In general widgets keep 'listening' to triggers, and hence consume battery and resources. I just want a simple button to launch my MyFileManager.
If widgets are the only solution, do you have a link/code to implement a very lightweight widget to do what I want? Or is this lightweight enough: http://www.javacodegeeks.com/2013/05/modal-dialog-popup-from-android-widget-example.html
Thanks!!
L.

How can I edit Android's application menu?

I would like to edit the application menu in Android (where all apps and widgets are displayed).
Like this:
I would like to create an app where you can select how the icons (applications) are shown in this menu. I'm not sure if it is even called "application menu" so I'm having some trouble to find some more info about this matter.
If anyone could help me find a way to override the original layout or point me in the right direction, that would be awesome!
Thanks in advance!
What you are showing in the pic, is called a Launcher.
You can create a custom Launcher. Check this question to get started.

How to create tabs on the button, and a setting page?

This is a bit difficult to explain, so I'll try to give a simple example to what I'd want to implement.
A. When the menu button is pressed in the Market app there are some kind of tabs on the buttom, how can I implement this ?
B.now press the settings (after you press the menu button in the Market app),
Is there a way to create this kind of a layout or I have to start from scratch (I would really appreciate code example for this if there is no 'easy' way to do this).
What you are referring to here is not a layout. This is the standard way of creating menues in Android applications.
Have a look at the following topic in the Android developer guide: http://developer.android.com/guide/topics/ui/menus.html
And regarding your second question: for settings/preferences, you can use a PreferenceScreen/PreferenceActivity. This is shown pretty well here: http://www.javacodegeeks.com/2011/01/android-quick-preferences-tutorial.html
If, by tabs you mean the buttons that pop up after clicking menu, you will have create your own options menu.
http://developer.android.com/guide/topics/ui/menus.html
EDIT: For B, check out the PreferenceScreen/PreferenceActivity, as mention in an answer to this post. Just updating here with link for convinience.
http://developer.android.com/reference/android/preference/PreferenceScreen.html
http://developer.android.com/reference/android/preference/PreferenceActivity.html

how to display an option menu when an activity starts

I've activity that i want an option menu to be displayed on. But, i want the option menu to be displayed all the time the activity is displayed. I don't want my users to click (select) the menu button to display it. I want it to be there all the time. How can i do it?
thanks
Activity.openOptionsMenu().
From a design standpoint, I have to agree with Mayra. Wrong approach to begin with.
If you want options to appear at the bottom of the screen always, don't use the options menu. Just place buttons at the bottom of your screen.
However, keep in mind that this goes against the "Android way" of doing things, so make sure you understand how Android users are going to expect your application to look and work, and you have a good reason for doing something different.

Categories

Resources