• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

control cursor keys using java code

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi....i am simran...i am working on a project"BLUETOOTH REMOTE CONTROL" n i am having a problem...
actually wat i want to do is ,i wannna control cursor using ma mobile's joy stick...like if i press left of my mobile's joystick,then cursor should move to the left and so on.....
so for that what can i do is i can pass command from my mobile to OS to activate some program which can handle cursor keys....
so neone have any idea how to do it???


[Nitesh: Removed bold font.]
 
simran gaur
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
guys ...what happened ....no reply......ok i am having another problem regarding my project...i am tryomg to send a file from my PC to my mobile phone.wen i run the following code,a message is displayed on my phone that "ACCEPT CONNECTION FROM [PCNAME]".but wen i accept the connection ,it gets disconnected...the two files are.........


send.java file

import java.io.*;
import java.io.File;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.IOException;

public class send extends Thread
{
String connection;

public byte[] getBytesFromFile(String file) throws IOException {

InputStream is = new FileInputStream(file);
System.out.println("\nDEBUG: FileInputStream is " + file);

// Get the size of the file
long length = file.length();
System.out.println("DEBUG: Length of " + file + " is " + length + "\n");

if (length > Integer.MAX_VALUE) {
System.out.println("File is too large to process");
return null;
}

// Create the byte array to hold the data
byte[] bytes = new byte[(int)length];

// Read in the bytes
int offset = 0;
int numRead = 0;
while ( (offset < bytes.length)
&&
( (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) ) {

offset += numRead;

}
is.close();
return bytes;
}

public static void main(String args[])
{
try{
send obj=new send();
byte[] filebytes=obj.getBytesFromFile("C:/Users/Sarbjit/Pictures/21.jpg");
Thread t=new Thread(new SendFileTask(filebytes,"abc"));
t.start();
}
catch(Exception e){}

}}



this is another file....



SendFileTask.java

import java.io.OutputStream;
import javax.microedition.io.Connection;
import javax.microedition.io.Connector;
import javax.obex.ClientSession;
import javax.obex.HeaderSet;
import javax.obex.Operation;


public class SendFileTask implements Runnable {

private String url;
private byte[] file;
private String filename;

public SendFileTask(byte[] file, String filename) {

this.file=file;
this.filename=filename;
}
public void run(){
try {

Connection connection =
Connector.open("btspp://0018427450CD:1;authenticate=false;encrypt=false;master=false");
// connection obtained
System.out.println(connection);
// now, let’s create a session
// and a headerset objects
ClientSession cs =
(ClientSession) connection;
HeaderSet hs = cs.createHeaderSet();

// now let’s send the connect header
cs.connect(hs);

hs.setHeader(HeaderSet.NAME, filename);
// content-type could be
// checked from a filename
hs.setHeader(HeaderSet.TYPE, "image/jpeg");
hs.setHeader(
HeaderSet.LENGTH,
new Long(file.length));

Operation putOperation = cs.put(hs);

OutputStream outputStream =
putOperation.openOutputStream();
outputStream.write(file);
// file push complete

outputStream.close();
putOperation.close();

cs.disconnect(null);

connection.close();
} catch (Exception e) {
e.printStackTrace();
}
}


}
 
Do the next thing next. That’s a pretty good rule. Read the tiny ad, that’s a pretty good rule, too.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic