Menu won't show up - Android Software Development

Hi Community,
I have a problem with implementing a menu, which should show up if the user presses the Menu-Button on his device. I followed the Dev Guide on developers.android.com and Overrode the onCreateOptionsMenu-Method, but if I press the Menu-Button on my VirtualDevice or my real Device, the Menu doesn't show up
Then I tried it the Not-XML-Way and implemented the onCreateOptionsMenu-Method like this:
Code:
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0,1,0,"Edit Contact");
menu.add(0,2,0,"Settings");
menu.add(0,3,0,"Exit");
return true;
}
But the menu still doesn't show up when I press the menu-Button.
I ensured via the debugger that the onCreateOptionsMenu is executed!
Anybody an idea what circumstance could prevent the showup of my menu?
I append my whole Javaclass if somebody could be that kind and would take a look, that would be very nice
Cheers
LordAlien
ps.: If somebody want to get an overview of this project I maintain it via git and have a gitweb frontend installed. Its located here http://aliens.homelinux.org/git/?p=rifle.git;a=summary

No one an idea what part of my code could influence the show up of my menu?
Every hint is highly appreciated!

This morning I had the helping flash of genius. I forgot to update the onKeyUp-Method, I only modified the onKeyDown-Method.
Now it works as expected

Always nice to see someone post when they solve it themselves.
Sent from my HTC Desire using XDA App

Related

Subclassing the Start Button

Hi All,
I cracked open Remote Spy++ and started figuring out how I could go about writing a Honeycomb start menu replacement for WM5-6.1 (seen the XP Start Replacement? Same idea). Having written something similar on desktop Windows I thought it would be easy. The app is in C#/CF.
So the window hierarchy is:
Code:
- Desktop
- HHTaskBar
- (nothing !!!)
And messages of interest (in order):
Code:
WM_LBUTTONDOWN (0x201)
WM_PAINT (0xF)
WM_INITMENUPOPUP (0x117)
Okay, so forgetting about the fact that the window is opaque (I will delve into this later on), I went ahead and subclassed it to catch the WM_LBUTTONDOWN message (the others didn't stop the original from showing up). That falls over (the debugger doesn't even break into code and the device needs a hard reset). I am investigating this - although my MessageBox shows up just before it dies.
Update: Using BeginInvoke with a worker method fixes the above issue. E.g:
Code:
public IntPtr NewWndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
{
if (msg == WM_LBUTTONDOWN)
{
this.BeginInvoke(new Action(DoWork));
return IntPtr.Zero;
}
return CallWindowProc(oldWndProc, hWnd, msg, wParam, lParam);;
}
private void DoWork()
{
Form2 two = new Form2();
two.Show();
}
So my question: the HHTaskBar is opaque, it has no child controls. Obviously, I don't want to subclass the battery/close/etc. buttons, and ideas on how to reliably retrieve the rect for the start button?
Or is the whole thing a hack? I suspect there is a way to do this without all this subclassing hackery. Google and forum search didn't turn up anything.
Thanks guys.
Source code
Usage: (not recommended on real device - use an emulator!) Click on button1 then click anywhere on the taskbar. Now reboot
I'd start with Quickmenu:
http://forum.xda-developers.com/showthread.php?t=471292
This app is the best start menu replacement I ever saw...
I'd only add a mixture of WKTASK's taskbar management and the ability to choose a icon for the start menu.
Thanks
twolf said:
I'd start with Quickmenu:
http://forum.xda-developers.com/showthread.php?t=471292
This app is the best start menu replacement I ever saw...
I'd only add a mixture of WKTASK's taskbar management and the ability to choose a icon for the start menu.
Click to expand...
Click to collapse
Thanks, it doesn't look like he has any source code available though. Looks like I will have to investigate more... I am not going for the drop down style (but as you said, it is really cool), I am trying to make a Honeycomb (WM 6.5) style menu.
I tried the wm6.5 honeycomb start menu... was not impressed, but maybe it had some extra something i didnt noticed... :/
I still haven't flashed my device with 6.5, but I reckon a FOSS honeycomb menu could be cool...
I think you'r on to something here. The start menu as it is in WM6.1 is pretty much useless. I would much rather have the start menu show me a application shortcut page like the one in WM6.5. Although to be honest I don't really like the honeycomb look. What's wrong with a plain old columns and rows type of thing. With the added physics scrolling/swiping stuff of course
frepe383 said:
I think you'r on to something here. The start menu as it is in WM6.1 is pretty much useless. I would much rather have the start menu show me a application shortcut page like the one in WM6.5.
Click to expand...
Click to collapse
Exactly! I am also hoping to replace that shoddy settings menu.
frepe383 said:
Although to be honest I don't really like the honeycomb look. What's wrong with a plain old columns and rows type of thing. With the added physics scrolling/swiping stuff of course
Click to expand...
Click to collapse
I think something with tabs (like Manila 2D) such as 'Programs', 'Running Programs', 'Settings' would be pretty useful. Skinning is a given, and honeycomb would be one (for the fanatics).
Update
I decided to call the tool Mead (as in the beer that contains honey ).
I was having problems with the default message pump and the hook (well, subclassed event). I am not sure which message was crashing my program, but if I use Application.Run() a native exception occurs in mscoree3_5.dll. The workaround is to create the form in the handler for the hook and show that one (it wasn't a UI thread being called from a worker, I am aware of that). So I think it must be a CF message pump bug. In any case, it works great now.
Quitting isn't all the way there yet, still some bugs (the type that will need a soft reset).
On to the UI stuff.
clickety
Excellent idea mate, but is it worth doing? the Beta 2 of 6.5 is already out and i am guessing its not long until the final version
Any news on this?
Nope
Nothing new. Just haven't had time between my job.
For now I am pinning it as the native call-in issue that the .Net CF suffers from (a documented limitation). Something isn't quite right.
I will continue to experiment, but push comes to shove, I will probably land up creating an interop library for it.
Instead of subclassing, you can just create a childwindow of HHTaskbar that is located over the start button.
Alternatively, you could suPerclass the "Explore" window class just to replace the Programs menu. Beware, that superclassing may be a bit dangerous
Interesting Idea
That is an interesting idea. When I get time I will start messing around with it.
That said I do expect some problems: again the interop call-in to .NET CF, but this may prove to work as a work-around .

Keyboard does not appear in my EditText fields

Hi, this is my first post so a big hello and I am hoping somebody might be able to help. I have just started Android development on the Galaxy Tab and have hit a major problem. I have created a basic view with various controls but I cannot get the virtual keyboard to come up. I have an EditText box and and AutoCompletingText box but neither work. If I select the EditText box (using my finger) you see a red line appear around the edge which I assume is indicating focus. However, the keyboard does not appear and the focus appears to disappear when I remove my finger from the box. I am using the official Galaxy sdk stuff with Eclipse.
Thanks for any assistance.
hztm said:
Hi, this is my first post so a big hello and I am hoping somebody might be able to help. I have just started Android development on the Galaxy Tab and have hit a major problem. I have created a basic view with various controls but I cannot get the virtual keyboard to come up. I have an EditText box and and AutoCompletingText box but neither work. If I select the EditText box (using my finger) you see a red line appear around the edge which I assume is indicating focus. However, the keyboard does not appear and the focus appears to disappear when I remove my finger from the box. I am using the official Galaxy sdk stuff with Eclipse.
Thanks for any assistance.
Click to expand...
Click to collapse
Maybe you can post the relevant part of your xml layout file in which you define the edit views and a part of the onCreate() method where you initiate those views.
BTW is there a specific SDK for the Galaxy? Or do you mean the Android SDK.
Hi, I am using the android sdk download from Samsung for the Galaxy tab and I am directing the program directly to the device rather than an emulator
I have the following in my main.xml file:
<EditText
android:id="@+id/EditText01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="30px"
android:layout_y="700px"
android:text="Hello"
android:inputType="text"
/>
I have the following onCreate.
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
factoids();
}
The field is displayed on the screen fine. If I select it with my finger then it is surrounded in blue as if it has got the focus. As soon as I remove my finger the blue focus disappears and the keyboard is never displayed. I normally program on PC and am slowly learning android / java so I expect I have something wrong but really not sure where to look now. Thanks for your assistance.
Yes, nothing wrong with this piece of code. Where do you instantiate the EditText? Maybe something is going wrong there.
Normally one instantiates a widget in the onCreate method; bind it to a variable so one can actually do something with it. In your case this would be:
Code:
EditText txtBox; (Define it in your class so it has full scope)
txtBox = (EditText) findViewById(R.id.EditText01);
Have you tried your own piece of code? Try it. Temporarily remove the factoids() call and it should run perfectly with a keyboard poping up in the editext box. If not there's something wrong with the sdk.
Hi,
Thank you very much indeed for your assistance and I have just managed to get it working. All I have done is copied the program to a new project with a new name and it is working. I have been programming VB.NET and C for years and always assume that it is me that has got it wrong so I must have damaged something in the original program.
Anyway, thanks again for your assistance.

[Q] Can We Hide The Status Bar?

There are some apps that need run full-screen and I am finding that the status bar interferes? Example, Softick Klondike Solitaire - unfortunately a great game but the developer put the score line so that it's hidden by the HoneyComb status bar. So I'd like to hide the status bar - there may be other apps that need this too
hide system bar
I have same question - I need to develop application for internal use, but without native 3.0 navigation (back, home, apps at system bar). One way I found - set ro.sf.lcd_density to 240, system think that this is mobile phone and change interface to show top status bar without any system bar, and status bar can be removed in program, but in this case I have to rebuild program layouts and this solution is not very good for other applications.
It look like system bar placed very deep inside android 3.0 code, so now I even thinking about porting android 2.3 to Iconia A500.
Any ideas?
z4gnom said:
I have same question - I need to develop application for internal use, but without native 3.0 navigation (back, home, apps at system bar). One way I found - set ro.sf.lcd_density to 240, system think that this is mobile phone and change interface to show top status bar without any system bar, and status bar can be removed in program, but in this case I have to rebuild program layouts and this solution is not very good for other applications.
It look like system bar placed very deep inside android 3.0 code, so now I even thinking about porting android 2.3 to Iconia A500.
Any ideas?
Click to expand...
Click to collapse
Transformer has Froyo running. http://forum.xda-developers.com/showthread.php?t=1078840
If I remember correctly, some XDA member got an A500 running Froyo to.. He bought it that way, but I dont know if he still has it.
Unless 3.1 or another update provides a solution, Honeycomb is stuck with it, which is lame for for a few reasons:
Easy to touch by mistake, and is no different than having a smaller display, since the space is taken by it. At least iOS gets this right and does not take up space. One of the few things they DID get this right.
just realized that system bar can be removed by killing systemUI service, this service is hidden in "running", but can be found in "all" and can be easily stopped.
now looking for program solution to kill it and restore by me application
I know there is a setting in Launcher Pro that you can hide it on phones, I dont know if it will work with this though.
Guys keep in mind this becomes less of an issue if you can get developers to update their apps for the Honeycomb SDK. There's a mode they call "lights out" that causes the system bar to dim tremendously - which is what the youtube app does.
Maybe instead of killing it, a third party app that causes it to go to dim mode and stay there - kind of a toggle - would be more appropriate so you don't lose the use of the buttons.
http://stackoverflow.com/questions/...-lights-out-mode-in-honeycomb/5097719#5097719
cybermage1 said:
Guys keep in mind this becomes less of an issue if you can get developers to update their apps for the Honeycomb SDK. There's a mode they call "lights out" that causes the system bar to dim tremendously - which is what the youtube app does.
Maybe instead of killing it, a third party app that causes it to go to dim mode and stay there - kind of a toggle - would be more appropriate so you don't lose the use of the buttons.
http://stackoverflow.com/questions/...-lights-out-mode-in-honeycomb/5097719#5097719
Click to expand...
Click to collapse
The brightness is not the issue, but the space the black bar takes up is. Kind of like the old CRT days when the bezel was quoted as part of the screen size. For 3.1 users, a 10.1" display is really 9.6, since space is taken up by the bar.
I went back to using my gTablet for now and notice that I have more display (though a display with awful angles).
Call me stupid, but I would prefer Gingerbread on the A500:
1. Games would work fine
2. Display resolution not compromised
3. Flash works fine
4. Less issues with legacy apps and Tiger Arcade has no scaling issues.
5. Actually, no apps have scaling issues with Gingerbread, but a lot do with Honeycomb, so need to wait/hope the devs update.
Yes, defeats the purpose of the tablet centric OS, but the bar at the bottom is a waste of display space.
"Honeycomb has a hidden Gingerbread (Android 2.3) UI within it.
And it can be very easily unhidden by simply changing the LCD density. Set it to 170 or higher, reboot, and you'll see all the graphical elements of Gingerbread (lock screen, dock, app drawer, keyboard, etc.); set it to 160 or lower and the Honeycomb you're used to will greet you after a reboot."
Sent from my GT-P1000 using XDA Premium App
the status bar has the soft keys... trust me, its nice to have since there are no hard keys for this device. this was a feature that was implemented for nook color in cyanogenmod because the lack of hard keys and it made all the difference. how are you going to press back or menu if you don't have that status bar? sure you could use the softkeys app or button savior but they are inconvienient and also put stuff on your screen.
Sent from my A500 using Tapatalk
com.android.systemui
I tested some ways to kill system bar:
1. Kill by adb shell: - su; ps, look for com.android.systemui; kill <PID> - success, sys-bar removed.
2. Settings, "Sytem UI" force stop - success, sys-bar removed.
3. Root explorer, delete /system/app/systemui.apk - got circle of error messages "com.android.systemui crashed, blabla...". Reboot, tablet started without system bar, no any errors, so success.
4. My app:
Code:
android.os.Process.killProcess(android.os.Process.getUidForName("com.android.systemui"));
failed, as expected, because my app can not kill process started by another app.
5. My app:
permission - android.permission.KILL_BACKGROUND_PROCESSES
Code:
final Context context = getApplicationContext();
servMng = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
servMng.killBackgroundProcesses("com.android.systemui");
Failed, no idea why.
6. Run script in my app to execute "ps", look for PID and execute "kill", not tested.
I need to implement option 5 or 6, can anyone give me some hints why 5 failed (or how to perform 6)?
Also I need to restore system bar using my app, I tested "am start blabla", it work in some cases throwing some errors and do not work in other cases depending on moon state, I do not know exact parameters for "am", also best solution to run in from app using java, any ideas how to do it "correctly"?
Lights Out mode
Part of the honeycomb API is a Lights out mode that dims the status bar so much that you can hardly see it. If you want to see it in action, just open the Kindle app.
Until 3rd parties update their full screen apps with this API, it would be nice for a third party app to implement it.
brunes said:
Part of the honeycomb API is a Lights out mode that dims the status bar so much that you can hardly see it. If you want to see it in action, just open the Kindle app.
Until 3rd parties update their full screen apps with this API, it would be nice for a third party app to implement it.
Click to expand...
Click to collapse
1st page...
http://forum.xda-developers.com/showpost.php?p=13981583&postcount=8
~~~~~
Greetings from XOOM land.
I was brainstorming a way to hide the status bar and bring it out again when needed. It seems Windows 8 will do just that, and will use the same method I had in mind.
The idea is to use a multitouch gesture to hide it and bring it back. Touch the screen with two fingers and swipe off of the bottom of the tablet screen as if flicking the status bar away, and it kills it. Swipe up from off the screen to bring it back.
Now, implementing this would be difficult, at least for me, but I think it would be awesome to get the bar out of the way sometimes.
arrtoodeetoo said:
Now, implementing this would be difficult, at least for me, but I think it would be awesome to get the bar out of the way sometimes.
Click to expand...
Click to collapse
try to implement option (one of) described in my 1st post on this page (#11)
here is developer.android.com/guide/topics/ui/actionbar.html google description how to remove action bar in 3.0+:
manifets
<activity android:theme="@android:style/Theme.Holo.NoActionBar">
or runtime
ActionBar actionBar = getActionBar();
actionBar.hide();
manifest do nothing, and code in runtime throw "force close blabla".
Anyone was able to do it this way?
added: hmm, it look like this is another one bar at top of screen, so do not pay attention to this post
Non-programatically you can kill it in Settings under manage applications, System UI.
Therefore, would it be posible to launch this settings page, send a couple of virtual D-PAD key presses to select the force quit button, and then Return key presses to press the button. Is this possible, using a persistant IME perhaps?
kill:
Code:
Process proc = null;
try {
proc = Runtime
.getRuntime()
.exec(new String[] { "su", "-c",
"service call activity 79 s16 com.android.systemui" });
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
proc.waitFor();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
restore:
Code:
Process proc = null;
try {
proc = Runtime.getRuntime().exec(
new String[] { "am", "startservice", "-n",
"com.android.systemui/.SystemUIService" });
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
proc.waitFor();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
and finally - root needed for two posts above.
credits: http://android.serverbox.ch/?p=306

[Q] Cursorloader causes weird behavior: e.g. onLoadFinished called continuously

Hey @ all,
I am creating an own app! This is my app's structure: own Application tests for startup and base Activity is used to spread the navigation drawer under all the following activities. On of these activities uses fragments in order to show lists. Please see my attachment for a graphical visualization.
I followed the guide on the developers site. I am a couple of problems, I will enumerate them in the following:
onLoadFinished is called all the time (indicated through Logcat output). I also found that the underlying contentprovider's query method is called all the time. as an additional information: I use notifyChange() on datasource manipulating methods in the content provider.
The list loads the data which is nice. but as soon as I navigate to another activity - using the navigation drawer causes a finish() call of the activity containing the list fragment -, I get an exception: RuntimeException since activity can't be destroyed. Besides that, I get a NPE because the listfragment's adapter is null what I do not understand as well.
If you need further information, please let me know asap! I'd love to provide it if you could help me. This really makes me sad .
Thank you so much in advance and greetz
mcmardy

[Q][solved] Beginner problem with OnCreateOptionsMenu

Hi,
I'm a french Android rookie, so excuse my english and my perhaps naive questions...
I am developing an app for Android (minSdk 14).
My main activity is a Processing PApplet, which has to be fullscreen, without an action bar.
From this activity, I want to launch a view to pass variables to my applet. I use onCreateOptionsMenu to open the options menu.
When I press the only item on this menu, I launch a "activity_settings"activity.
So far so good, but it bothers me that the user has to press the Options button, then the "Settings" button in the options menu.
So I tried to directly launch my "activity_settings" activity in onCreateOptionsMenu, without inflating the options menu.
It works the first time, but then "activity_settings" doesnt want to open any more ...
If I do the same thing using onPrepareOptionsMenu instead of onCreateOptionsMenu, it works and works again without problems ...
I do not understand why! If any nice coder wants to explain to me ... that would be nice!
Another issue, I cannot capture the size of an OnTouch event .
Code:
@Override
public boolean onTouchEvent(MotionEvent event) {
Log.d("Touched", String.valueOf(event.getSize()));
return super.onTouchEvent(event);
}
LogCat always shows "Touched" 0.0
Is it because of my device? Samsung GT7560 (Galaxy Trend)
Thank you in advance!
marzinp said:
Hi,
I'm a french Android rookie, so excuse my english and my perhaps naive questions...
I am developing an app for Android (minSdk 14).
My main activity is a Processing PApplet, which has to be fullscreen, without an action bar.
From this activity, I want to launch a view to pass variables to my applet. I use onCreateOptionsMenu to open the options menu.
When I press the only item on this menu, I launch a "activity_settings"activity.
So far so good, but it bothers me that the user has to press the Options button, then the "Settings" button in the options menu.
So I tried to directly launch my "activity_settings" activity in onCreateOptionsMenu, without inflating the options menu.
It works the first time, but then "activity_settings" doesnt want to open any more ...
If I do the same thing using onPrepareOptionsMenu instead of onCreateOptionsMenu, it works and works again without problems ...
I do not understand why! If any nice coder wants to explain to me ... that would be nice!
Another issue, I cannot capture the size of an OnTouch event .
Code:
@Override
public boolean onTouchEvent(MotionEvent event) {
Log.d("Touched", String.valueOf(event.getSize()));
return super.onTouchEvent(event);
}
LogCat always shows "Touched" 0.0
Is it because of my device? Samsung GT7560 (Galaxy Trend)
Thank you in advance!
Click to expand...
Click to collapse
Regarding the onCreateOptionsMenu, It works the first time only because this method is called only once when the activity is created, and the options menu is created.
The onPrepareOptionsMenu is called every time it the menu is shown, like every time you go back to the activity (The activity is resumed not created).
alphascript said:
Regarding the onCreateOptionsMenu, It works the first time only because this method is called only once when the activity is created, and the options menu is created.
The onPrepareOptionsMenu is called every time it the menu is shown, like every time you go back to the activity (The activity is resumed not created).
Click to expand...
Click to collapse
Thanks a lot, I didn't figure that! Ishould have!
For the second part of my question, it's definitely my device that isnt able to mesure pressure nor size of the touch.
Showing pointers from the dev options gave me the answer. Now I have to figure another way of capturing the touch size...
marzinp said:
Thanks a lot, I didn't figure that! Ishould have!
For the second part of my question, it's definitely my device that isnt able to mesure pressure nor size of the touch.
Showing pointers from the dev options gave me the answer. Now I have to figure another way of capturing the touch size...
Click to expand...
Click to collapse
See:
https://groups.google.com/forum/#!topic/android-developers/10pF8EUEuy0

Categories

Resources