Hi,
My Midlet is running well in emulator. But the same application when I deployed in Nokia 7210 Supernova, the Canvas is not displayed. The Ticker appended to the Canvas is Displayed.
Suggestion appreciated in advance.
Hi,
My Midlet is running well in emulator. But the same application when I deployed in Nokia 7210 Supernova, the Canvas is not displayed. The Ticker appended to the Canvas is Displayed.
Suggestion appreciated in advance.
Last edited by bidyut84; 2010-01-22 at 12:35.
Could you post any code so we can atleast get a hint what might be the problem. Any exceptions?
Do you mean this 7210 (supernova), or this, original 7210?
The original 7210 is CLDC-1.0, MIDP-1.0, and if you have used features of CLDC-1.1 or MIDP-2.0, your application will not work. Develop for CLDC-1.0/MIDP-1.0 if you want to use your application on a device with that specification.
Graham.
Edit: Ah, I see you've edited your original post after reading my reply, so you no longer talk about a MIDP-1 7210.
Last edited by grahamhughes; 2010-01-23 at 11:00. Reason: Original post has been edited.
package hello;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.midlet.*;
public class TestMidlet extends MIDlet {
public void startApp() {
TestCanvas TCObject = new TestCanvas();
Display.getDisplay(this).setCurrent(TCObject);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}
class TestCanvas extends Canvas{
protected void paint(Graphics g) {
g.setColor(0,0,0);
Font font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_SMALL);
g.setFont(font);
g.drawRect(0,0,getWidth(),getHeight());
g.setColor(255,255,255);
g.drawString("Welcom to 3G", 0, 0, 0);
}
}
Last edited by bidyut84; 2010-01-22 at 13:16.
Below is the code I am using to display the Canvas in a nokia device. The Device is showing on ly a white screen, No Exception.
Below is the part of my actual code, the varriable path is the first part of the url which gives the Background Image and audio.
fieldarray is a string array .
Note the point that the code is working fine in emulator.
All the background images and audio are coming accordingly.
But in nokia 7210 Supernova , its displaying only a white screen.
protected void paint(Graphics g) {
width = getWidth();
height = getHeight();
g.setColor(255, 0, 0);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(255, 255, 255);
g.fillRect(0, 0, width - 1, height - 1);
try
{
g.drawImage(getImage(path + bgImg + ".png"),0, 0, Graphics.TOP | Graphics.LEFT);
}catch(Exception e)
{
e.printStackTrace();
}
g.setColor(255, 255, 255);
int y = 20;
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_LARGE));
g.drawString(header, 70, 0, Graphics.TOP| Graphics.LEFT);
for (int i=0;i<fieldArray.length;i++){
y = y+40;
g.setFont(Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD, Font.SIZE_MEDIUM));
g.drawString(fieldArray[i] , 50, y, Graphics.TOP | Graphics.LEFT);
}
if(!audioStr.equals("") && !audioStr.equals("null")){
String audio=path + audioStr +".amr";
//play(path + audioStr + ".amr");
play(audio);
}
}
It's hard to say without seeing all the code. The problem might lie in the paint() method.
How is getImage() working? What is the path? Ideally, load images in advance of paint(). As with any event method, paint() should return as quickly as possible, and you should avoid slowing it down with IO operations. The path for an image should start with "/" if using createImage(). Note that createImage() does not take a URL as it's argument.
It's also a bad plan to play audio in the paint() method. The paint() method is for painting. Don't do anything else.
This part may be the source of your problem. In particular, why are you comparing audioStr with the string "null"? Possibly, audioStr is null (not "null"), and this is throwing a NullPointerException. Try changing this to:
You must have the check for null on the left of the &&. If the left-hand expression is false, the right-hand expression will not be evaluated. This will prevent the right-hand expression from throwing a NullPointerException if audioStr is null.Code:if (audioStr != null && audioStr.length() > 0) {
It's also possible that the problem occurs somewhere else, such as startApp().
Graham.
I have found the cause of the problem, Actually we are using a tomcat Server as our web server. The problem is that midlet is not able to get any Image or audio from the sever.
when I use a static image then the application is running well but audio and text content that we are trying to get from server are not playing or shown.
Any advice ?
what do you mean by using static images ????????
Moreover after reading the whole scenario I guess you are downloading the images , sound, text from your server and using it in your app and as u say now u used static image I think u are using an image bundled with your midlet but still using the sound and text from server by downloading m I correct
Regards,
Saurabh
sorry for late reply well if dat the case then since you are saying that when u use bundled images they work so its problem with ur server or either with your code through which you are fetching all dat resources
Try using all resources(images, sound, text) as static i.e bundled them in ur midlet and gave it a blow
Regards,
Saurabh
Thanks for advice buddy. But with my lill knowledge what I found is, if there is an issue related to code, then it wouldnt work in emulator also. Isn't ?