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

Native Development

Reply
Developer
Posts: 45
Registered: ‎11-16-2013
My Device: Z10
My Carrier: AT&T

Check internet in splash screen and change the position of a button in Toast

Hello,



Now i'm using check the internet in app, but i need check this in splash screen and don't run app and Stopped at the splash screen.

 

And i need change the position of a button in Toast

example:

 

 122222222222222.png

 

my code:

 

void ApplicationUI::showToast ( QString Msg, QString butnMsg, bool showButton )
{
   SystemUiButton* toastRetryBtn = NULL;

   if (showButton)
   {
      toastRetryBtn = currentToast->button();
      toastRetryBtn->setLabel(butnMsg);
   }

   currentToast->setBody(Msg);
   currentToast->setPosition(bb::system::SystemUiPosition::MiddleCenter);
   currentToast->show();
}

 

 

 

Developer
Posts: 826
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Rogers

Re: Check internet in splash screen and change the position of a button in Toast

[ Edited ]

the only way to get the button in a different location is to create your own toast (easiest by using a dialog)

 

if you need to need to check something before your qml is loaded, do this in the constructor of your app before you load the qml page.  

 

if you want a splash screen to persist while you adjust the button based on the internet connection result just create an imageview that contains your splash screen and have it visible by default and then change its visiblity whenever you decide the user should be allowed through into the application.

Developer
Posts: 45
Registered: ‎11-16-2013
My Device: Z10
My Carrier: AT&T

Re: Check internet in splash screen and change the position of a button in Toast

Hello slashkyle,

 

Ok for toast .

 

But for check is there another solution.

Developer
Posts: 826
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Rogers

Re: Check internet in splash screen and change the position of a button in Toast

I'm not sure how you're doing the check or exactly what your intention is, if you check for internect connection before you open your qml file then that info will be readily avaliable to pass to the toast i'm assuimng this is what you want to do. 

 

You can run this process after you load the qml and just use the imagview to cover your content while you do the check and present the 'toast'.  you can then destroy or turn these elements visbility off when you're ready to show the rest of your content

 

to do that it would basically be

 

main.qml

 

Page {
  Container {
    id: root
    layout: dockLayout {}
   
    Container {
       id: everythingElse
       //all your stuff needs to be before the imageview
    }    

    ImageView {
       id: splashScreen
       horizontalAlignment: HorizontalAlignment.Fill
       verticalAlignment: VerticalAlignment.Fill
       imageSource "assets://images/splash768x1280.png"
       
    }

    attachedObjects: [
         Dialog: {
            id: toastDialog
            Container {
                //put your buttons here
                
            }
         }
    onCreationCompleted: {
        //assuming you do the check after
        cpp.checkForInternet()
        /*open the toast if/when you need it
          make sure you turn image view visible to false or
          at some point or the user wont be able to use your app*/
          
    }

    ]

  }
}

 assuming this is what you're trying to do

Highlighted
Developer
Posts: 45
Registered: ‎11-16-2013
My Device: Z10
My Carrier: AT&T

Re: Check internet in splash screen and change the position of a button in Toast

Thanks man.

But Is there another solution, without using ImageView.
e.g. using c++ for that.

Developer
Posts: 826
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Rogers

Re: Check internet in splash screen and change the position of a button in Toast

you could create the imageview in c++, or really anything to cover the screen but I'm not sure if it would completely cover the entire screen like the imageview in qml would... anythings possible though so give it a try Smiley Wink

 

I mainly work with qml, but if you can find a viable c++ alternative there's nothing wrong with that

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Check internet in splash screen and change the position of a button in Toast

Use a Sheet to simulate a splash screen...

 

http://developer.blackberry.com/native/reference/cascades/bb__cascades__sheet.html

 

If you are going to do it this way then you should also read up on static asset selection...

 

http://developer.blackberry.com/native/documentation/cascades/best_practices/resolution/using_static...


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 826
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Rogers

Re: Check internet in splash screen and change the position of a button in Toast

the only downside i see to a sheet as opposed to imageview is the user will see the sheet opening, the imageview will be there looking exactly like the splash screen until it is removed

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Check internet in splash screen and change the position of a button in Toast

The trouble with your suggestion is that whatever navigation route is chosen by the OP will still be present unless an awful lot of extra work is done to prevent this. Depending on how long the internet check is it's possible without this code that the user will just continue on regardless.

 

With a sheet that prevention is already there.

 

Your assumption is also wrong about the display as well as there is no reason you can't have two roots, one the Sheet and one the main program and switch between the two depending on the internet check.

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 45
Registered: ‎11-16-2013
My Device: Z10
My Carrier: AT&T

Re: Check internet in splash screen and change the position of a button in Toast

@slashkyle

Yeah, Now the question you can do so without the use of imageview?
I will try it.

________________________________________________________________

@BBSJdev

@slashkyle He is right