All Mobile Development
This is a blog for those who are new to mobile development field . But now its under construction . All mobile development on one Blog.
Monday, January 7, 2013
Sunday, January 6, 2013
Play Voice Notes in Blackberry App
String file_name ;//name of file or path of voice note to play
try
{
FileConnection con = (FileConnection)Connector.open(file_name , Connector.READ);
InputStream is = con.openInputStream();//create an instance of the player from the //InputStream
Player player = javax.microedition.media.Manager.createPlayer
(is, "audio/amr");
player.realize();
player.prefetch();
//start the player
player.start();
}
catch(MediaException me)
{
System.out.println("Audio Play Start" + me.toString());
}
catch(IOException ioe)
{
System.out.println( "Audio Play Start " + ioe.toString());
}
Tuesday, December 18, 2012
Pie Graph in BlackBerry , Android and J2ME
1) Define array of data and array of colors.
int[] data = { 16, 14, 16, 10, 4 };
int colors[] = { Color.RED , Color.LIGHTBLUE ,Color.YELLOW, Color.GREEN,Color.BLUE};
/////////////////////
2) Other parameters
int width = 200; // width of area where pie graph is drawn.
int height = 200; //height of area where pie graph is drawn.
int sum = 0;
int deltaAngle ;
int x = 0; //starting point where area of pie graph drawn (you can change this as per your choice)
int y = 0; //
int diameter;
//////////////////////
3)Calculation
sum = 0;
for (int i = 0; i < data.length; i++) {
sum += data[i];
}
deltaAngle = 360 * 100 / sum / 100;
if (width > height)
diameter = height - y * 2;
else
diameter = width - x * 2;
/////////////////
4)Paint function
protected void paint(Graphics graphics) {
graphics.setColor(Color.BLACK);
graphics.fillRect(0, 0, width, height);
graphics.clear();
int startAngle = 0;
for (int i = 0; i < data.length; i++)
{
graphics.setColor(colors[i]);
graphics.fillArc(x, y, diameter, diameter, startAngle, deltaAngle * data[i]);
startAngle += deltaAngle * data[i];
}
}
Saturday, December 15, 2012
Convert Vector to String Array in Java
Vector v = new Vector();
v.add("1");
v.add("2");
v.add("3");
v.add("4");
String[] s = String[v.size];
for(int i = 0 ; i < g.v.size() ; i++){
s[i] = (String) g.v.elementAt(i);
}
..............................
OutPut String Array
s[] = {"1","2","3","4"};
Subscribe to:
Posts (Atom)