Top 7 Things About Mobile Games Future

Given a choice between console games and those played on mobile phones, the mobile phone games are being preferred by a large segment of people from different walks of…

  1. Given a choice between console games and those played on mobile phones, the mobile games are being preferred by a large segment of people from different walks of life. And the reasons are quite obvious. Gaming enthusiasts can play these mobile phone games and mobile Java games at their own discretion, whenever they want and wherever they want to!
  2. There is far greater flexibility for them to indulge in a few moments of “mobile gaming action,” even during their busy day at work. And with most people of our times possessing a mobile phone handset of their own, there are endless opportunities to be explored!
  3. Another factor that has contributed to the wide-spread popularity of mobile phone game downloads is the availability of a wide variety of the same at affordable costs. Easy to download and compatible with the latest models of handsets, the mobile phone games and Java games have become one of the most common ways of entertainment in the modern world.
  4. The development of mobile phone technology has contributed to this trend. Most of the latest mobile phone handsets from the leading names in the industry come with colored screens, enhanced memories and stereo sounds. These advanced features go a long way to give a whole new dimension to the mobile gaming experience.
  5. However, this is not the end of the road. Or, we can say that the journey of mobile games has just begun. The present generation of wireless networks need further up gradation. This would enable faster transfer of data and enable people to play mobile games and mobile Java games in real time.
  6. The pricing policy regarding the download of mobile phone games and mobile Java games also need some changes. Mobile network operators need to take steps to encourage potential customers of mobile games to browse the Internet.
  7. They would then be motivated to download extra gaming levels to their handsets. According to the opinion of experts, a change in the pricing policy would lead to a further “opening up” of the market for mobile phone game downloads and mobile Java games.

Reference: http://top7business.com/?id=1621

J2ME – in Ubuntu

First of all, I want to say myself as a J2ME expert. In my university life I spent too much time in it. However come to the point, after completely changed my platform from Windows to Ubuntu Linux I’m free from pirated software.

For developing java application j2se+j2me I prefer to use NetBeans IDE. In ubuntu it’s very easy to install. But after installing I could develop j2me application using it but the emulator doesn’t run perfectly. I tried many times and installed all J2SE runtime and library like gcj …. and more … But I was failure to run using NetBeans IDE’s Emulator for J2ME.

Today I download the J2ME development environment from java.sun.com. I installed it and it runs perfectly. I could run j2me application also.

But I need to run application from NetBeans IDE. So I did this, tools->java platform->add platform
Then I set the location /opt/WTK2.5 . NetBeans IDE detects J2ME platform. And finally I’m success and happy to run J2ME application in Ubuntu using NetBeans IDE.

A J2ME application that connects and read data from HTTP protocol

This example shows you how to connect and read data from a http protocol. When you implement it and run it from your mobile device, you have to change the url from localhost to a real hosting address. (Like http://www.ftechdb.com/somefile.txt)

/*
* Midlet.java
*
* Created on March 14, 2007, 1:15 PM
*/

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.*;

/**
*
* @author  mahmud
* @version
*/
public class Midlet extends MIDlet {
private Display display;
private Form form;
public void startApp() {
display = Display.getDisplay(this);

form = new Form(“Http Example”);
StringBuffer buffer = null;

try{

// you could use other http://www.something.com/file.html as a example

String url = “http://localhost/shaon.txt”;

StreamConnection conn = (StreamConnection) Connector.open(url);
InputStream in = conn.openInputStream();

buffer = new StringBuffer();
int ch;

while ( (ch = in.read())!= -1){
buffer.append( (char) ch);

}
}
catch(Exception o){
o.printStackTrace();
}

form.append(new StringItem(null, buffer.toString()));
display.setCurrent(form);
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}
}

Posted in J2ME. Tags: , , . 1 Comment »

Know your Mobile – A simple j2me application

This is a very simple code of j2me. By implementing it, and running it by your mobile device, you could learn some attributes of Java configuration of your mobile device.

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

public class AttributesMIDlet extends MIDlet{
private Display display;
private Command cExit;

public void startApp(){
display = Display.getDisplay(this);

cExit = new Command(“Quit”, Command.EXIT, 0);

Canvas canvas = new DummyCanvas();

Runtime runtime = Runtime.getRuntime();
Form form = new Form(“Attributes”);

form.append(new StringItem(“Know Your Mobile”, “”));
form.append(new StringItem(“Total Memory:”, String.valueOf(runtime.totalMemory()/1024)+”Kb”));
form.append(new StringItem(“Free Memory:”, String.valueOf(runtime.freeMemory()/1024)+”Kb”));
form.append(new StringItem(“n”, null));
form.append(System.getProperty(“microedition.configuration”));
form.append(System.getProperty(“microedition.profiles”));

boolean isColor = display.isColor();

form.append(new StringItem(isColor ? “Colors:”: “Grays:”, String.valueOf(display.numColors())));
form.append(new StringItem(“Width: “, String.valueOf(canvas.getWidth())));
form.append(new StringItem(“Height:”, String.valueOf(canvas.getHeight())));
form.append(new StringItem(“Repeat:”, String.valueOf(canvas.hasRepeatEvents())));
form.append(new StringItem(“Double Buff:”, String.valueOf(canvas.isDoubleBuffered())));

form.addCommand(cExit);
form.setCommandListener(
new CommandListener(){
public void commandAction(Command c, Displayable d){
if (c == cExit){
destroyApp(false);
notifyDestroyed();
}
}
}
);

display.setCurrent(form);
}
public void pauseApp(){
}
public void destroyApp(boolean unconditional){
}
}

class DummyCanvas extends Canvas{
public void paint(Graphics g){
;
}
}

Posted in J2ME. Tags: , . 6 Comments »

Here I’ll show, how to play a wav sound from a JAR file

To play a wav file we must include the Mobile Media API 1.1 (MMAPI 1.1) JSR 135.

At first I given the source code then explain it.

import javax.microedition.media.*; // This is the package you must include

try{
Player wavPlayer;
InputStream is = getClass().getResourceAsStream(“sound.wav”);
wavPlayer = Manager.createPlayer(is, “audio/X-wav”);
wavPlayer.prefetch();
wavPlayer.start();
}
catch(Exception o){
o.printStackTrace();
}

Player interface acts as a remote control to play all type of audio.
Manager.createPlayer() method is used to create a player. Here the first parameter is the source and second is the type of audio file.
wavPlayer.prefetch() method retrieving the audio and minimize latency.
wavPlayer.start() method start and play the audio.

There are some other methods necessary for controlling the player.
wavPlayer.setLoopCount(int number) . This method sets the number of times a sound is looped when play it.
If number is -1, then the loop will continue to infinite time.
wavPlayer.stop() method stop the playing audio.
wavPlayer.close() method close the player and release the resource.

Posted in J2ME. Tags: , , , , , , . Leave a Comment »

Communication between J2ME client and PHP page in server

Sometimes it’s very necessary to communicate between a J2ME client and a PHP page in the server.
Here I have shown a J2ME program that communicate with PHP page in server.
I showed here HTTP GET method. But it is similar for POST method. I also showed the POST
method’s syntax in this article. I choose php page because, PHP server is most popular.

Here is the J2ME Program:
This program get a number from user and send this to the php page in server. Server read and
send necessary output as a return .

/*
* Client.java
*
* Created on August 17, 2007, 11:42 AM
*/

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

import java.io.*;
import javax.microedition.io.*;

/**
*
* @author ahsan
* @version
*/
public class Client extends MIDlet implements CommandListener {
private Display display;
private Form form;
private Command cQuit, cOk;
private String url = "http://yourphppage.php?type=";
private String part="";
private TextField f;

HttpConnection http;
InputStream in;
OutputStream out;
int rc;

public void startApp() {
display = Display.getDisplay(this);
form = new Form("Client");
cQuit = new Command("Quit", Command.EXIT, 1);
cOk = new Command("OK", Command.OK, 1);

f = new TextField("Query", "",10, TextField.NUMERIC);

form.addCommand(cQuit);
form.addCommand(cOk);
form.setCommandListener(this);
form.append(f);

display.setCurrent(form);
}

public void processGet() throws Exception{
http = (HttpConnection) Connector.open(url+part);
http.setRequestMethod(HttpConnection.GET);
http.setRequestProperty("IF-Mofified-Since", "10 Nov 2006 17:29:12 GMT");
http.setRequestProperty("User-Agent", "Profile/MIDP-2.0 Configuration/CLDC-1.1");
http.setRequestProperty("Content-Language", "en-US");

in = http.openDataInputStream();
out = http.openDataOutputStream();

rc = http.getResponseCode();
if (rc != HttpConnection.HTTP_OK) {
throw new IOException("HTTP response code: " + rc);
}

int ch;
StringBuffer buff = new StringBuffer();
while ( (ch = in.read())!= -1){
buff.append( (char) ch);
}
form.append(new StringItem("Response: ", buff.toString()));

if (in != null)
in.close();
if (out != null)
out.close();
if (http != null)
http.close();

}

public void commandAction(Command com, Displayable d){
if (com == cQuit){
destroyApp(true);
notifyDestroyed();
}
else if (com == cOk){
part = f.getString().trim();
try{
processGet();
}
catch(Exception o){
o.printStackTrace();
}
}
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}
}

Now I have shown the PHP page that read the data from J2ME client and
display the necessary output to the J2ME client’s display:


hello.php

<?php
$response = "Hello, every body";

if (isset($_GET)){
switch($_GET["type"]){
case 1: $response = "Good Moring"; break;
case 2: $response = "Good evening "; break;
case 3: $response = "Visit: http://www.ftechdb.com"; break;
default: $response = "Hi to all" ;
}
}
echo "$response";
?>
Please use this syntax in the php page when using POST method both in J2ME client
and PHP page
:

if ($_SERVER['REQUEST_METHOD'] == 'POST')
$str = trim(file_get_contents('php://input')); //get the raw POST data