i'm re writing an app with codename one for other devices other android.
On the simulator everything is working fine, iv'e got some buttons that, when pressed, give access to an HTML page, the actual code for this is:
wifi.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ev){
Form form = new Form("WiFi");
Container container = new Container();
WebBrowser wb = new WebBrowser();
container.addComponent(wb);
wb.setURL("jar:///assets/html/wifi.html");
System.out.println("url:"+wb.getURL());
Command backCommand = new Command("Back") {
public void actionPerformed(ActionEvent ev) {
wifi.getComponentForm().showBack();
}};
form.addCommand(backCommand);
form.setBackCommand(backCommand);
form.addComponent(container);
form.show();
}
});
When i first want to getURL() back, the string is empty; then when i want to build for an android device (Galaxy Nexus with Android 4.3) when i tap on the button it returns me nothing but a blank page.
I also tried with an http link like https://www.google.com, on simulator no problem, on device the usual blank page.
Then i tried modifying the position of the html file, putting it in src like for the image file (that works on device), but still nothing.
I've checked the developer guide and every example i could find, and everyone got no problem with this (and on the simulator me neither). Could anyone solve this?
Thank you :)
Place the file in the root of the src directory and point directly at it without the assets hierarchy for it to work properly across platforms.
Related
So I'm using LibGDX and RoboVM to convert my Android project to an iOS app. I'm trying to share an animated GIF that the user has just created and saved to their device, here's what I have so far:
public void shareGif(String path)
{
NSData data = new NSData(Gdx.files.absolute(path).readBytes());
NSArray<NSData> nsObjectsToShare = new NSArray<NSData>(data);
ArrayList<String> excludedActivities = new ArrayList<String>();
excludedActivities.add(UIActivityType.Print());
excludedActivities.add(UIActivityType.AddToReadingList());
excludedActivities.add(UIActivityType.PostToVimeo());
excludedActivities.add(UIActivityType.PostToTencentWeibo());
UIActivityViewController share = new UIActivityViewController(nsObjectsToShare, null);
share.setExcludedActivityTypes(excludedActivities);
((IOSApplication)Gdx.app).getUIViewController().presentViewController(share, true, null);
}
Now, this does work. It successfully opens the share window and sends an animated GIF via Mail and Message. Twitter, however, only seems to share a static image (it appears to actually be a JPG when I examine it on my Twitter timeline).
Anyone have any ideas how I can get Twitter to share the ANIMATED version of the GIF? I know I'm not using Objective-C like with typical iOS apps but I'm hoping you can still make out what's going on in the above code.
Was apparently fixed in iOS 8. Just updated my device and it works now. Cool.
I have encountered a small problem that I need some help on. The issue is that I wish to call a browser window which calls a html page. The html file opens in 3 different browsers so the code for that should be correct. The actual problem is that it brings up a page can't be displayed error message
Here is the code that gets the location
package org.error;
public class BrowserLocation {
private String test1 = "org\\error\\PatientNumberError.html";
public BrowserLocation() {
}
public String patientNumberAddress() {
return test1;
}
}
and here is the code that creates the browser component and calls the location of the html file.
Browser browser = new Browser(container, SWT.NONE);
browser.setForeground(SWTResourceManager.getColor(SWT.COLOR_DARK_BLUE));
browser.setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
browser.setUrl(browserLocation.patientNumberAddress());
browser.setBounds(25, 25, 315, 180);
Would it be possible to find the error of my ways?
setUrl require a URL so you need something like:
browser.setUrl(new File(path).toURI().toURL().toString());
Sorry for not getting back to you earlier.
Someone that I know who is a senior Java programmer told me the problem that I was having was a case of absolute address versus relative address.
The reason for this is that if I was reading and writing to a file, then I would be able to use a relative address. However If I'm interacting with a server which is the case here as eventually It could go on-line (If I had the money) it would need to be an absolute address.
As I am still learning Java programming this was a very specific and important lesson to learn. I hope this would help anybody else who has had this issue.
Scenario:
1. My JavaFX desktop app is running full screen.
2. Through it, I ask the operating system to open a new file (.doc, .ppt, .avi etc.) with the default app used for that type.
3. I want to keep the Java/JavaFX app in full screen while the new file is opened by another file (Word etc).
Problem: my app goes out of full screen when I try to do this, but that's exactly what I don't want. I want to keep my app in full screen and the other program that opens the file to be shown over my app, while I'm still in full screen.
Does anyone have any ideas how this could be implemented and if it's possible? I'm looking for solutions for both Windows and OSX.
Thanks a lot!!!
You can restrict your application not to go out of full screen by
primaryStage.fullScreenProperty().addListener(new ChangeListener<Boolean>() {
#Override
public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
if (!ov.getValue()) {
primaryStage.setFullScreen(true);
}
}
});
I am developing J2ME application with lwuit and Codenameone and created it in lots of time. After I created it I wanted to deploy it in some devices like Nokia, Samsung, LG and etc. that they supported MIDP. So I figure out Nokia devices run it with no error and Samsung and other companies devices have some problems that I can't understand why?!
So I tried different way of creating this application. I used Codenameone wizard with blank theme and manual template and then I tried to deploy it. Well, that right. I got success and it ran in Samsung devices too.
After that I tried to add some forms to "theme" in this appliaction and run it in simulator. I changed some code in my main class like this:
public class Main extends UIBuilder {
private Form current;
public void init(Object context) {
try{
Resources theme = Resources.openLayered("/theme");
UIManager.getInstance().setThemeProps(theme.getTheme(theme.getThemeResourceNames()[0]));
}catch(IOException e){
e.printStackTrace();
}
}
public void start() {
if(current != null){
current.show();
return;
}
Form hi = findMain();//new Form("Hi World");
//hi.addComponent(new Label("Hi World"));
hi.show();
}
public void stop() {
current = Display.getInstance().getCurrent();
}
public void destroy() {
}
public com.codename1.ui.Form findMain() {
return (com.codename1.ui.Form)findByName("Main", Display.getInstance().getCurrent());
}}
I got error when I ran it.
So this is my questions:
I created one application in Visual Mode of Codenameone.
How can I run it in Samsung and some other devices like Samsung (without opertaing system, just support java or MIDP)?
How can I change my Visual Mode application to Manual Mode in Codenameone?
Thanks in advance.
You are deriving from UIBuilder within the lifecycle class and trying to use a finder method on something that isn't showing yet. There is absolutely no way that your code works in the simulator and it is not the code that was generated by the wizard.
Thanks Shai. For creating I did hard coding and create all of forms one by one.
I implement base Form that derive from com.codenameone.ui.Form and every forms derive from base Form.
I am developing the network application in which I want to run my J2ME MIDP application in background without any GUI so that is any way to construct the application is such manner.
try this
set your current Display to null. so there will not be any form or alert running on the screen. But however your code will be running in the background.
Display display = Display.getDisplay(this); // here 'this' points to Midlet
display.setCurrent(null);
it easy just have a code of line on any event for example in the click of button
Display.getDisplay (this).setCurrent (null);
and return back the control via
Display.getDisplay (this).setCurrent (mycanvas);
Yes this code works Good,
display = Display.getDisplay(this);
public void startApp()
{
display.setCurrent(form);
}
public void pauseApp()
{
}
public void hide()
{
Display.getDisplay (this).setCurrent (null);
}
This is will work like, make a button can after clicking it call hide Function, or you call this hide function in constructor so it will hide itself when app start, can you keep unHide statement in appStart() so if you Tab the program then it will unHide app again.
NOTE: you said you are working on Network app, but some mobile will turn off the Internet Connection, when the Mobile screen Turn Off. please check this. and If you found any solution It will be Good to share here.