This is the code i m running in my blackberry bold 9900 simulator but the BrowserField just shows the blank white screen and nothing. Is there any problem with my simulator or some setting needs to be done in it. Thanks in advance for help.
public class StartUp extends UiApplication
{
public static void main(String[])
{
StartUp start=new StartUp();
start.enterEventDispatcher();
}
public StartUp()
{
MainScreen screen = new MainScreen();
BrowserField browserField = new BrowserField();;
screen.add(browserField);
pushScreen(screen);
browserField.requestContent("http://www.google.com/news");
}
}
Verify if you have a network connection in your simulator, see this development guide article.
Related
I'm having an issue with libGDX's otherwise great scene2d ui library when running my app in landscape mode. My program works as expected in both the android simulator and the desktop environment, but when I run it on the iOS simulator or a real device, the main menu is drawn as if the phone were still in the portrait orientation, and the just cropped to fit in a landscape view. At first, I assumed I had just screwed up, as I'm still learning the api, but the app works just as expected on android. I have configured my game to run in landscape mode on both iOS and android.
On the android simulator, the menu works as expected. The simulator is in landscape orientation, and properly displays the menu.
On iOS, the menu is off center and unclickable.
I pretty sure that the problem has to do with landscape mode, because everything works fine in portrait orientation. Here's my code for the MainMenuScreen, which extends a ScreenAdapter.
package bakpakin.techgame;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton.TextButtonStyle;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
/**
* Created by Calvin on 9/25/14.
*/
public class MainMenuScreen extends ScreenAdapter {
private TechGame game;
private Stage stage;
private Skin skin;
private Table table;
public MainMenuScreen(TechGame game) {
this.game = game;
}
#Override
public void show() {
this.stage = new Stage();
this.skin = new Skin();
skin.add("default", Assets.superScript48);
skin.add("title", Assets.superScript128);
TextButtonStyle textButtonStyle = new TextButtonStyle();
textButtonStyle.font = skin.getFont("default");
textButtonStyle.pressedOffsetY = 4;
skin.add("default", textButtonStyle);
Label.LabelStyle labelStyle = new Label.LabelStyle();
labelStyle.font = skin.getFont("title");
labelStyle.fontColor = Color.CYAN;
skin.add("default", labelStyle);
// Create a table that fills the screen. Everything else will go inside this table.
table = new Table();
table.setFillParent(true);
stage.addActor(table);
final TextButton play = new TextButton("Play", skin);
final TextButton about = new TextButton("About", skin);
final TextButton quit = new TextButton("Quit", skin);
play.addListener(new ChangeListener() {
#Override
public void changed(ChangeEvent event, Actor actor) {
Assets.button1Sound.play(1, 1, 0);
}
});
about.addListener(new ChangeListener() {
#Override
public void changed(ChangeEvent event, Actor actor) {
Assets.button1Sound.play(1, 1, 0);
}
});
quit.addListener(new ChangeListener() {
#Override
public void changed(ChangeEvent event, Actor actor) {
Assets.button1Sound.play(1, 1, 0);
Gdx.app.exit();
}
});
final Label title = new Label("My Game", skin);
VerticalGroup vg = new VerticalGroup();
vg.pad(60);
table.add(title);
table.row();
table.add(vg);
vg.addActor(play);
vg.addActor(about);
vg.addActor(quit);
Gdx.input.setInputProcessor(stage);
}
#Override
public void render(float delta) {
GL20 gl = Gdx.gl;
gl.glClearColor(0, 0, 0, 1);
gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
stage.act(delta);
stage.draw();
}
#Override
public void dispose() {
stage.dispose();
skin.dispose();
}
}
IOS 7 or 8? I heard there are some iOS 8 rendering issues
Apparently this is fixed in the latest snapshot (see github.com/libgdx/libgdx/issues/2386). With a new stable release promised real-soon-now, I'm sure the fix will be folded in if you're not brave enough to run snapshot builds
I am trying to change the current profile of the phone to Silent. I am looking for the API to do this. These options are accessible via the Speaker icon on the main blackberry screen.
How i can change the profile programmatically?
There is no way you can change the profile of a blackberry device programatically. Sad but true
It's currently NOT supported to change profile programmatically from normal to silent. Following are some links you might find useful.
BlackBerry Support Forums: how to change profile programatically from normal to silent??
blackberryforums.com: Programatically Change Profile
I see this question in Blackberry Developer Zone;
We only change the profile status(Means silent --> Loud like this) but we cannot change the settings (means you cannot change the slient's profile settings or Loud's profile settings);
see the sample code;
public final class LoadingScreen extends MainScreen implements FieldChangeListener
{
public LoadingScreen()
{
createGUI();
}
private void createGUI()
{
try
{
ApplicationManager.getApplicationManager().launch("net_rim_bb_profiles_app");
}
catch (Exception e)
{
//Exception
}
}
public void fieldChanged(Field field, int context)
{
}
}
i am developing an application which contain alternative entry point.
and i put tick mark in "Do not display in Blackberry Home screen". here it is working fine it does not show icon on the home screen. but my problem is that
when i am click on SwitchApplication from menu(Home screen), the alternative entry point icon is showing on the popup screen like following image. i dont want to show that icon.i want hide that icon programatically.
please help me
You can hide app if it's service. Set system module (systemmodule) to true for bb ant tools. There is similar options for JDE and Eclipse plugin.
just override this method into our application
like following
private static boolean flag=false;
public static void main(String[] args)
{
StartUp startUp;
if(args!=null && args.length>0 && args[0].equals("gui")){
flag=false;
startUp = new StartUp("gui");
startUp.enterEventDispatcher();
}else{
flag=true;
startUp = new StartUp();
startUp.enterEventDispatcher();
}
}
i override this method
protected boolean acceptsForeground() {
return flag;
}
This is the code that I ended up using that worked for me. I had tried putting the acceptsForeground in my main launcher class at first, but then put it in PushListener itself instead to prevent it from appearing in the running tasks menu. Worked fine.
Launcher Class
public static void main(String[] args) {
if (args != null && args.length > 0 && args[0].equals("gui")) {
MyApp app = new MyApp();
app.enterEventDispatcher();
} else {
PushListener.waitForInstance().start();
}
}
PushListener Class
protected boolean acceptsForeground() {
return false; // You could use a variable instead if you wanted.
}
It's quite simple if you use blackberry eclipse plugin.
open "blackberry_description_app.xml", just check this: Don't display the app icon on blackberry home screen.
I need to display a splash screen when I app instantiate, I wrote a class for splashScreen based on blackberry develpers knowlwdebase (link).
And its invoked from my following class.My problem is the splashscreen appears only after a deley,How can I solve it,If any one have idea Please help me,Thanks
class Test extends MainScreen{
Test(){
UiApplication.getUiApplication().invokeLater(new Runnable()
{
public void run() {
UiApplication app=(UiApplication)getApplication();
Bitmap image = Bitmap.getBitmapResource("splah.png");
ListView listView = new ListView();
new SplashScreen(app, listView );
}
}
Try synchronized (UiApplication.getEventLock()). It is faster than invokeLater.
Test(){
synchronized (UiApplication.getEventLock()) {
UiApplication app=(UiApplication)getApplication();
Bitmap image = Bitmap.getBitmapResource("splah.png");
ListView listView = new ListView();
new SplashScreen(app, listView );
}
}
Please can anyone help me with my issue - what is the way to know that browserfield2 has finished loading in Blackberry.
I need to set some options after loading. Does browserfield2 have some methods to show that?
Here is some code that will get you started.
BrowserField browserField = new BrowserField();
BrowserFieldListener listener = new BrowserFieldListener() {
public void documentLoaded(BrowserField browserField, Document document) throws Exception
{
// the document has loaded, do something ...
}
}
browserField.addListener( listener );