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
Developer
Posts: 23
Registered: ‎06-05-2009
My Device: Not Specified
Accepted Solution

check registartion at start up? best way to implement

Hey guys,

 

I have been trying to determine the best way to have my application check for a valid registration key on startup and if the key is valid the app runs.  If the key is not there or invalid it presents a pop up screen to enter a registration code.   Any and all help would be appreciated in getting me pointed in the right direction.

 

(I have the pop up screen already created)

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: check registartion at start up? best way to implement

I would use the PersistentStore to store the key value. You can load and evaluate the key value at startup.

 

If it isn't there, then you'll push your dialog.

 

Developer
Posts: 23
Registered: ‎06-05-2009
My Device: Not Specified

Re: check registartion at start up? best way to implement

hey, thanks for the response..

 

I have the key stored in persistent data now.. I guess my main question is how do i check it?

 

	public MyApp() {
		if (Integer.valueOf(regkey.getText()).intValue()==DeviceInfo.getDeviceId())
		{
			PopUp popUp = new PopUp();
			UiApplication.getUiApplication().pushScreen(new PopUp());
		}else{
	}
		AppMainScreen screen = new AppMainScreen();
		pushScreen(screen);
    	}

 I tried this implementation but it does not work, I get a nullpointerexception in the sim...

 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: check registartion at start up? best way to implement

I don;t understand what you are doing with this popup?

 

First you instantiate Popup(), then you instantiate another Popup() in your pushScreen call.

 

It's hard to tell from this snippet, but it also looks like you are trying to get a reference to UiApplication when there isn't one? Where did you enter the event dispatcher?

 

 

 

 

Developer
Posts: 1,305
Registered: ‎01-21-2009
My Device: Not Specified

Re: check registartion at start up? best way to implement

You are doing this check too early in the process. Try something like this:

 

 

public class MyApp extends UiApplication {

  public static void main(String[] args) {
    final MyApp app = new MyApp();
    app.invokeLater(new Runnable() {
      public void run() {
        app.doStartupWork();
      }
    }
    app.enterEventDispatcher();
  }

  void doStartupWork() {
    if (!registered()) {
      PopUp popUp = new PopUp();
pushModalScreen(popUp);
if (popUp.registrationFailed()) {
System.exit(0);
}
 } pushScreen(new AppMainScreen());
} boolean registered() { // check for existing registration key } }

 

 




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Developer
Posts: 23
Registered: ‎06-05-2009
My Device: Not Specified

Re: check registartion at start up? best way to implement

This is what I needed..thank you very much!