Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 7
Registered: ‎08-31-2010
My Device: 9500

Menu Problem on MainScreen

Hi,

 

I've problem in accessing menu. I will explain the step I do:

 

I've implanted Splash Screen ( Call S1) in my application using Observer Pattern.

 

S1 shows progress bar and does network call in background.

Based on result and as per business logic, I popour Splashscreen and push Application Screen 1 ( call it A1). 

 

A1 - has custom manager and sub manager. Sub manager's layout holds  EditFeild, 2 - Object Choice feild and a Button. Submanger is been added to the manager and manager is been added to A1 in constructor of A1. Also I've created menuitem M1.

 

I've also overridden makeMenu method in A1 and add M1 to menu.

 

Problem :

 

S1 shows progress bar and in the end A1 is visible. When A1 is visible, and if I press Menu button ( button with RIM icon on emulator) or back key, application cashes out.

 

In debugger, I can see onMenu and keycharunhandled is been called and the last call is made ot persistance.commit and error shown there is illegalstate exception.

 

I am sure there is not error on persistence but somewhere in my implementation of menu or it is due to multiple screen. 

 

Going through various documents and API documentation. I could n't find help for the case so I came to experts!!!

 

Please do help with your views.

 

I've no problem in sharing the code but i thought I wold explain first.

 

Also I tried out various thing like starting application with A1 straight i.e. pushing A1 instead S1 ( ofcosurse I disabled all my business logic) and there on clicking menu button I can see the menu.

 

So I am left really clueless about what could be wrong?

 

Thanks for reading out.

 

-Hemal

Developer
Posts: 16,788
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Menu Problem on MainScreen

welcome to the support forums!

 

as a first step i would suggest that you check all your UI calls to be made on the event thread.

if you have some from your background processing you may need invokelater or similar.

 

what happens if you don't overwrite makeMenu and press the menu key?

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Regular Contributor
Posts: 98
Registered: ‎08-31-2010
My Device: BB-9700
My Carrier: Airtel

Re: Menu Problem on MainScreen

Did you try using debugger to know exact issue and detail message about the exact issue from the OS. Also paste some code snippet to get more understanding.

New Developer
Posts: 7
Registered: ‎08-31-2010
My Device: 9500

Re: Menu Problem on MainScreen

Hi,

Fist of all thanks for reply @simon_hain and @Abhijit_RIM for reply.
I've used invoke later on pushscreen and thus screen visible perfectly.
So I didn't understood where else i should be using invokelater?
Here is debug trace from actual App ( with business logic):

 

Thread [Cinemati(181)id=295001088] (Suspended (exception NonPersistableObjectException)) Persistence.commit(Object, boolean) line: 51 PersistentObject.commit() line: 149 UiOptionsRegistry(OptionsRegistry).setInt(long, int) line: 471 UiOptionsRegistry(OptionsRegistry).getIntParam(long) line: 193 UiOptionsRegistry(OptionsRegistry).getInt(long) line: 182 UserSettingsScreen(Screen).onMenu(int) line: 3890 UserSettingsScreen(Screen).keyCharUnhandled(char, int, int) line: 3029 UserSettingsScreen(MainScreen).keyCharUnhandled(char, int, int) line: 320 UserSettingsScreen(Screen).dispatchKeyEvent(IKeyEvent) line: 697 UserSettingsScreen(Screen).processKeyEvent(IKeyEvent) line: 3440 UiEngineImpl.processMessage(Object, Message, boolean) line: 3635 HomeScreen(Application).doProcessNextMessage(Message) line: 2268 HomeScreen(Application).processNextMessage(Message) line: 1530 HomeScreen(Application).enterEventDispatcher() line: 1371 

  HomeScreen.main(String[]) line: 83 

 

I get same or similar error and trace in case of makeMenu is overridden and not overridden.

 

New Developer
Posts: 7
Registered: ‎08-31-2010
My Device: 9500

Re: Menu Problem on MainScreen

Any help or more suggestion?

Developer
Posts: 16,788
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Menu Problem on MainScreen

NonPersistableObjectException means that you try to persist an object that does not implement the Persistable interface. i don't see how it is connected to your original problem though.

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
Posts: 7
Registered: ‎08-31-2010
My Device: 9500

Re: Menu Problem on MainScreen

Hi,

 

Exactly, I am also not able to understand the connection here. I am adding data to persistance store but that is done on event of button click. This is also done by a static method call of other class and what object I am persisting has implemented  marker interface Persistable. Moreover I used same method call at other places in the application and it don't give any error.

 

What makes me more amusing that this error been raised on click of menu button on emulator.

My method for persisting the data should only be called on button or particular menu click event. But by just mere clicking on menu button application crashes out instead of showing the Menus!!!

 

I am really getting clueless here what should I do? 

 

Thanks for your reply Simon anyway.

 

-Hemal

Developer
Posts: 16,788
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Menu Problem on MainScreen

i would suggest you do some debugging.

comment out all code from your make menu method. does it run?

switch the menu items in one by one. etc

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
Posts: 7
Registered: ‎08-31-2010
My Device: 9500

Re: Menu Problem on MainScreen

Hi,

 

as per your suggestion I did commented out all the code in makeMenu method and

 

just put the   trace  System.out.println(" Inside make menu");

 

but its not getting printed out on console in eclipse it seems makeMenu is not called atall. As per debug info it goes to onMenu method of UserSettingScreen. I've not provided or overridden onMenu method in my code.

 

What could be reason for this?

 

-Hemal

Highlighted
New Developer
Posts: 7
Registered: ‎08-31-2010
My Device: 9500

Re: Menu Problem on MainScreen

any suggestion?