Hello, i have a few questions regarding - writing software and using that software in my cell phone.

-Which language is best for cell phone software?
- Can i use java, and would that be the easiest?
-where do i even start when i begin to write a cell phone based program?

Can someone who has experience with writing cell phone software help me?:cool:

ok i have been reading around and J2ME seems like it may be a good start to writing a program/game on a cell phone.

There is number of programming languages available for mobile development

  • C# under .NET Compact Framework for Windows CE - easy to learn, fast development, large number of devices available however not portable and most of available libraries have to be acquired for larger amount of money (nothing new in Microsoft driven library development)
  • Symbian C++ - based upon the C++ with variety of own approaches to coding, numerous free libraries available, huge community support however I found difficulties to work with the language because of messed up API, with each new version there are portability issues
  • Java Microedition - in contrast to C# and Symbian, JME is portable to all devices expect iPhone so you have huge number of devices to test your application. As it is Java based with having previous experiences with Java anyone will progress fast. Well based industry support with libraries constantly being reviewed and update as necessary plus huge community support. Main disadvantage is JME is not able query underlying phone OS as C# and Symbian, therefore for example you can not launch your application on phone start up or start the application on some phone event
  • Android - new platform which seen release of new device just this October, as stated on their website "Applications are written using the Java programming language and run on Dalvik, a custom virtual machine designed for embedded use, which runs on top of a Linux kernel." Is one of the item on my To-Do list, but not the important
  • BREW - the APIs are provided in C with a C++ style interface, is rather difficult to learn, very few devices available, you have to pay for application testing before you an get it available for use
  • Python is trying to get into mobile development so far is available natively only on Nokia Series60

Choice of the language is yours.
In case you want to go with Java Microedition there is special "Starting Java" post for JME, here

commented: damn you're good :) well, either that or you spend a lot of time on Google +3
commented: Good info. +15

I think J2me is nice for cell phone.

ok! BIG HELP ill see how i can manage all of this, with my school standing on my path

K its been like two months since i posted this, i havent really gotten any far, i was using http://devlinslab.blogspot.com/2007/10/getting-started.html for some sort of Java based cell phone tutorial , i used NETBEANS IDE, to write the code, it was rather difficult following the directions, just because i wasnt sure how to fix the Errors, i would like to get back to the errors, one day if someone would actually go over that LINK and take some time to look at my code, to see what is wrong with my code.

If you provide code and stack trace for errors there are many that may help you...

K wanna tell me how to send u code, and stack trace for errorss, ill be happy to follow ur instructions

I have Netbeans IDE 6.1 opened for you ATM.

Either use code tags to make it part of post [code] YOUR CODE HERE [/code] or use advance posting option ( press "Go Advanced" button) and bellow post editing area you will find Manage Attachments button which will allows you to upload code (*.java) or compressed source files (*.zip)

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MyGame;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.game.GameCanvas;
import javax.microedition.midlet.MIDlet;

public class clsCanvas extends GameCanvas
        implements Runnable {

    private boolean isRunning = true;
    private Graphics g;
    private midMain fParent;

    public clsCanvas(midMain m) {
        super(true);
        fParent = m;
    }

    public void start() {
        Thread runner = new Thread(this);
        runner.start();
    }

    public void run() {
        int iKey = 0;
        g = getGraphics();
        while (isRunning) {
            iKey = getKeyStates();

            if ((iKey & GameCanvas.FIRE_PRESSED) !=
                    0) {
                isRunning = false;
            }

            //set drawing color to black
            g.setColor(0x000000);
            //fill the whole screen
            g.fillRect(0, 0, getWidth(), getHeight());
            // set drawing color to white
            g.setColor(0xffffff);
            //display the key code last pressed
            g.drawString(Integer.toString(iKey), 2,
                    2, Graphics.TOP | Graphics.LEFT);
            flushGraphics();
            try {
                Thread.sleep(30);
            } catch (Exception ex) {
            }
        }
        g = null;
        fParent.destroyApp(false);
        fParent = null;

there it is, i dont think it is showing the errors, idk

Sorry this class is not completed and you missing MIDlet, what you want me to do with that?

yes please, if it will run correctly, and show what it sopose to show.

AND could you also tell me what i did wrong , and what u did to correct it

You see this constructor

public clsCanvas(midMain m)

it is expecting some argument to be passed down from previous MIDlet, Canvas or Form
plus you calling

fParent.destroyApp(false);

that is always implemented in MIDlet, also you missing two closing bracklets on the end of code which you provided (see your post with the code).

So no, this will not compile and therefore it will not run.

What ever should i do to make it run again?

not again..i mean for the first time

Here is a better example. This example will show you how you can monitor button presses and what sort of information you can get out of it. KeyCanvas class is taken from Jonathan Knudsen book Kicking Butt with MIDP and MSA, chapter 9.13
MIDLET: ButtonEvents.java

package buttonEvents;

/**
 * Created by IntelliJ IDEA.
 * User: Peter
 * Date: 23-Dec-2008
 * Time: 11:18:42
 */

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;

public class ButtonEvents extends MIDlet implements CommandListener {
    private Canvas mCanvas;
    private Command mOKCommand;

    public void startApp() {
        Display display = Display.getDisplay(this);
        if (mCanvas == null) {
            mCanvas = new KeyCanvas();
            mOKCommand = new Command("OK", Command.OK, 0);
            mCanvas.addCommand(mOKCommand);
            mCanvas.setCommandListener(this);
        }
        display.setCurrent(mCanvas);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
        if (c == mOKCommand) {
            destroyApp(true);
            notifyDestroyed();
        }
    }
}

CANVAS: KeyCanvas.java

package buttonEvents;

/**
 * Created by IntelliJ IDEA.
 * User: Peter
 * Date: 23-Dec-2008
 * Time: 11:20:15
 */

import javax.microedition.lcdui.*;

public class KeyCanvas extends Canvas {
    private String mMessage = "Press any key!";
    private int mKeyCode;

    public void paint(Graphics g) {
        int w = getWidth();
        int h = getHeight();
        g.setColor(0xffffff);
        g.fillRect(0, 0, w, h);
        int fh = g.getFont().getHeight();
        int y = h / 2 - fh * 2;
        int kc = mKeyCode;
        g.setColor(0x000000);
        g.drawString(mMessage, w / 2, y,
                Graphics.HCENTER | Graphics.BOTTOM);
        y += fh;
        if (kc != 0) {
            String kn = getKeyName(kc);
            if (kn == null) kn = "";
            int ga = getGameAction(kc);
            String gn = getGameActionName(ga);
            g.drawString("Key code: " + kc, w / 2, y,
                    Graphics.HCENTER | Graphics.BOTTOM);
            y += fh;
            g.drawString("Key name: " + kn, w / 2, y,
                    Graphics.HCENTER | Graphics.BOTTOM);
            y += fh;
            g.drawString("Game action: " + gn, w / 2, y,
                    Graphics.HCENTER | Graphics.BOTTOM);
        }
    }

    protected void keyPressed(int keyCode) {
        mMessage = "keyPressed()";
        mKeyCode = keyCode;
        repaint();
    }

    protected void keyReleased(int keyCode) {
        mMessage = "keyReleased()";
        mKeyCode = keyCode;
        repaint();
    }

    protected void keyRepeated(int keyCode) {
        mMessage = "keyRepeated()";
        mKeyCode = keyCode;
        repaint();
    }

    private String getGameActionName(int gameAction) {
        String name = "";
        switch (gameAction) {
            case UP:
                name = "UP";
                break;
            case DOWN:
                name = "DOWN";
                break;
            case LEFT:
                name = "LEFT";
                break;
            case RIGHT:
                name = "RIGHT";
                break;
            case FIRE:
                name = "FIRE";
                break;
            case GAME_A:
                name = "GAME_A";
                break;
            case GAME_B:
                name = "GAME_B";
                break;
            case GAME_C:
                name = "GAME_C";
                break;
            case GAME_D:
                name = "GAME_D";
                break;
            default:
                break;
        }
        return name;
    }
}

THank you, i hope that wasnt to much effort, you put into this. ill try compiling that, and then running it, and see what happens lol.

so, how am i gonna run that sort of code, with out the Number list?

so, how am i gonna run that sort of code, with out the Number list?

Please explain yourself this doesn't make sense to me.

It makes sense to me

If you look at the code, you sent to me, it has a Number List.

My question was do i Add those numbers such as 1, 2,3,4,5,6 ..ect.

or do i disinclude them?

There is no such thing as Number list, provided code uses information already included in API and only game buttons have extra detection to show what game actions are associated with them and print these in string format.
So if you want to capture only game actions you need to exclude

String kn = getKeyName(kc);
if (kn == null) kn = "";
// AND
g.drawString("Key name: " + kn, w / 2, y,
                Graphics.HCENTER | Graphics.BOTTOM);
y += fh;

Did that answer your question?

i feel tension between the discussion of what is a number list, and what you dont "beleive exists"

example of number list

1.
2.
3.
4.
5.
ect..

your adding these in the beginning of code, do i include or not include that?

i define it as a number list, you dont even seem to see what i am talking about.


besides that, ur also sending me other stuff, i didnt ask for, that does not mean i am not interested in trying it, but the Original Post was about getting that little bit of CODE correct, u seemed to point out my errors, then send me other bits of RAndom code, i dont mind that, but it didnt really help me from my OP, besides you telling me my error, the my IDE, already did.

LOL, these are because of code formatting if I use [code]

[/code] you will get this view

String kn = getKeyName(kc);
if (kn == null) kn = "";
// AND
g.drawString("Key name: " + kn, w / 2, y,
                Graphics.HCENTER | Graphics.BOTTOM);
y += fh;

however if I add language declaration as [code=Java] [/code] you will get you number list

String kn = getKeyName(kc);
if (kn == null) kn = "";
// AND
g.drawString("Key name: " + kn, w / 2, y,
                Graphics.HCENTER | Graphics.BOTTOM);
y += fh;

So when ever you copy code that been formated with code tags you should click (Toggle Plain Text) which will get you text area from which you can easily copy code and no number lines will be included

ok Thank you

hi i am siva...i want to know how to write a program of chess game by using java or c

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.