Handy -PC Verbindung

nemo86

Mitglied
Hallo alle,

ich möchte eine Anwendung schreiben bei der ein simuliertes Handy mit meinem PC kommuniziert. Implementiere ich die Kommunikation zwischen zwei Handys, die beide simuliert auf dem PC laufen, funktioniert alles perfekt, möchte ich aber den Client als PC Anwendung starten (die Logik nicht verändert), findet er den Server nicht. Alle externen Geräte wie z.B. mein Handy oder andere PC werden dabei erkannt, aber eben nicht das simulierte. Kann mir jemand sagen, wo das Problem liegt?
 

Atze

Top Contributor
zeile 304, oder könnte auch 306 sein, schmeißt ne nullpointer ...

ne, mal im ernst, ohne code schwer zu sagen. vielleicht kann dir jemand helfen, wenn man code sieht :)
 

nemo86

Mitglied
Alles klar:) Also Server aufm Handy

Java:
public class Server {
	private UUID serverUUID = new UUID("F0E0D0C0B0A000908070605040302010",
			false);
	private StreamConnectionNotifier notifer;
	private InputStream input;
	private OutputStream output;
	private boolean init;
	private String SERVER_RESPONSE = "Server is ready";
	private boolean isActive=false;
public Server() {
		initServer();
	}

	private void initServer() {
		try {
			LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.GIAC);

			// prepare a URL to create a notifier
			StringBuffer url = new StringBuffer("btspp://");
			url.append("localhost").append(':');
			url.append(serverUUID.toString());
			url.append(";name=Diving Computer Server");
			url.append(";authorize=false");

			notifer = (StreamConnectionNotifier) Connector.open(url.toString());

			StreamConnection conn = notifer.acceptAndOpen();

			init = true;

			input = conn.openInputStream();
			output = conn.openOutputStream();
			
			isActive=true;
			System.out.println("*******Server*******");
			
			output.write(SERVER_RESPONSE.length());
			output.write(SERVER_RESPONSE.getBytes());

		} catch(BluetoothStateException e){
			System.out.println("Cannot initialize bluetooth");
			System.out.println(e);
		} catch (IOException e) {
			System.out.println("IOException");
			e.printStackTrace();
		}
	}

Und Client aufm PC
Java:
public class Client implements DiscoveryListener {
	private UUID serverUUID = new UUID("F0E0D0C0B0A000908070605040302010",
			false);
	private DiscoveryAgent agent;
	private boolean init = false;
	private boolean serverFound = false;
	private String url;
	private final String CLIENT_RESPONSE = "Client is ready";
	private OutputStream output;
	private InputStream input;
	private boolean isActive = false;
	private boolean complete=false;
	
	public boolean isActive(){
		return isActive;
	}
	public boolean isCompleted(){
		return complete;
	}

	public Client() {
	}

	public void searchDevices() {
		try {
			agent = LocalDevice.getLocalDevice().getDiscoveryAgent();
			agent.startInquiry(DiscoveryAgent.GIAC, this);
		} catch (BluetoothStateException e) {
			System.out.println("Problem in searching the blue tooth devices");
			System.out.println(e.getMessage());
		}
	}

	public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {
		try {
			// Get Device Info
			System.out.println("Device Discovered");
			System.out.println("Major Device Class: "
					+ cod.getMajorDeviceClass() + " Minor Device Class: "
					+ cod.getMinorDeviceClass());
			System.out.println("Bluetooth Address: "
					+ btDevice.getBluetoothAddress());
			System.out.println("Bluetooth Friendly Name: "
					+ btDevice.getFriendlyName(true));

			// Search for Services
			UUID uuidSet[] = new UUID[1];
			uuidSet[0] = serverUUID;
			agent.searchServices(null, uuidSet, btDevice, this);
		} catch (Exception e) {
			System.out.println("Device Discovered Error: " + e);
		}
	}

	public void inquiryCompleted(int discType) {
		System.out.println("InquiryCompleted");
		complete=true;
	}

	public void serviceSearchCompleted(int transId, int respCode) {
		StreamConnection conn;
		if (serverFound) {
			try { // lets the communication start by setting the url and send
				// client reponse
				conn = (StreamConnection) Connector.open(url);

				output = conn.openOutputStream();
				input = conn.openInputStream();

				System.out.println("*******Client*******");
				
				output.write(CLIENT_RESPONSE.length());
				output.write(CLIENT_RESPONSE.getBytes());

				isActive = true;
				System.out.println("serviceSearchCompleted");
			} catch (IOException ex) {
				ex.printStackTrace();
			}
		}

	}

	public void servicesDiscovered(int transId, ServiceRecord[] records) {
		for (int i = 0; i < records.length; i++) {
			url = records[i].getConnectionURL(
					ServiceRecord.AUTHENTICATE_ENCRYPT, false);

			if (url.startsWith("btspp")) {
				init = true;
				serverFound = true;
				break;
			}
		}
	}
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
G Bluetooth Verbindung zwischen Handy und PC Android & Cross-Platform Mobile Apps 5
K Android Logging auf dem Handy Android & Cross-Platform Mobile Apps 6
Android App auf das eigene Handy bekommen Android & Cross-Platform Mobile Apps 3
J Android zugrif auf Thread nach Handy drehen. Android & Cross-Platform Mobile Apps 10
M Zugriff auf Helligkeitsregler von Handy? Android & Cross-Platform Mobile Apps 17
P Daten bzw Objekte auf das Handy lokal speichern Android & Cross-Platform Mobile Apps 29
N Wie kann ich mein Handy mit Java rooten? Android & Cross-Platform Mobile Apps 38
R Android App vom Handy dekompilieren Android & Cross-Platform Mobile Apps 4
D Android Android Apps direkt vom Handy aus programmieren? Android & Cross-Platform Mobile Apps 2
B Android App debugen auf Handy, Handy-Desktop auf PC anzeigen Android & Cross-Platform Mobile Apps 1
M Error beim drücken der Zurück-Taste am Handy Android & Cross-Platform Mobile Apps 2
G Auslesen von RFID mit dem Handy Android & Cross-Platform Mobile Apps 3
J Handy bootet nicht mehr richtig Android & Cross-Platform Mobile Apps 2
R Android Datenaustausch zwischen PC und Handy Android & Cross-Platform Mobile Apps 3
K Zeitstopp-App, immer dann aktiv, wenn Handy an - wie vorgehen? Android & Cross-Platform Mobile Apps 4
X Android Handy mit Eclipse verbinden Android & Cross-Platform Mobile Apps 1
T Android Handy in Eclipse einbinden Android & Cross-Platform Mobile Apps 34
A AVD läuft, Handy stüzt ab Android & Cross-Platform Mobile Apps 2
J Apps für Android programmieren - Android Handy notwendig oder reicht Simulator? Android & Cross-Platform Mobile Apps 3
A Handy mit Arduino verbinden Android & Cross-Platform Mobile Apps 4
B Java auf dem Handy Android & Cross-Platform Mobile Apps 5
E Java ME Installation auf Handy Android & Cross-Platform Mobile Apps 2
K Java ME Handy Java App die die Navigationstasten abfragt Android & Cross-Platform Mobile Apps 7
R Handy Java Version Android & Cross-Platform Mobile Apps 18
A Probleme mit Calendar auf dem Handy Android & Cross-Platform Mobile Apps 3
G GPS am Nokia Handy auslesen (Anfänger) Android & Cross-Platform Mobile Apps 15
C Export auf Handy Android & Cross-Platform Mobile Apps 2
O Entwickler für Java Anwendungen auf Handy gesucht! Android & Cross-Platform Mobile Apps 3
B Programme aufs Handy ziehn! Android & Cross-Platform Mobile Apps 2
C Programm nicht auf Handy installierbar (Zertifikatfehler) Android & Cross-Platform Mobile Apps 3
I Java Handy - mehrere Programme gleichzeitig Android & Cross-Platform Mobile Apps 8
Screen Java auf Handy,aber nicht Ja2Me ! Android & Cross-Platform Mobile Apps 3
Q einfaches Countdownprogramm Handy Android & Cross-Platform Mobile Apps 10
L HTML Seite anzeigen in Handy-Applikation Android & Cross-Platform Mobile Apps 5
B Java PC Spiel fürs Handy umwandeln? Android & Cross-Platform Mobile Apps 8
T Handy akzeptiert jar nicht Android & Cross-Platform Mobile Apps 12
2 Netbeans Handy Projekt läuft nicht auf Handy! Android & Cross-Platform Mobile Apps 3
M Symbol im Handy Android & Cross-Platform Mobile Apps 2
L Kann App auf Handy nicht ausführen Android & Cross-Platform Mobile Apps 5
Q Handy unterstützt format an Android & Cross-Platform Mobile Apps 18
W Java auf ein CECT Handy installieren Android & Cross-Platform Mobile Apps 6
G SMS über Handy SMS Interface versenden Android & Cross-Platform Mobile Apps 5
loadbrain sony ericsson handy, MIDP 2.0 Android & Cross-Platform Mobile Apps 6
A Java Programm auf Handy? Android & Cross-Platform Mobile Apps 2
S Handy als fernbedienung Android & Cross-Platform Mobile Apps 8
M Handy als Webcam Android & Cross-Platform Mobile Apps 18
R ME-Neuling: welches Prepaid-Handy kaufen? Android & Cross-Platform Mobile Apps 5
K Anwendung für Handy programmieren Android & Cross-Platform Mobile Apps 1
G Bildershow auf Handy Android & Cross-Platform Mobile Apps 2
luke86 Programm von Handy zu Handy weitergeben(NOKIA N70) Android & Cross-Platform Mobile Apps 3
B Textdatei auf Handy erstellen / lesen / schreiben? Android & Cross-Platform Mobile Apps 2
TheJavaKid handy java comiler Android & Cross-Platform Mobile Apps 5
1 zugriff auf handy-microfon Android & Cross-Platform Mobile Apps 2
J J2ME Java Programm im Hintergrund auf Handy laufen lassen? Android & Cross-Platform Mobile Apps 2
G Programm auf handy installieren Android & Cross-Platform Mobile Apps 3
N Wie ist das mit der Handy API? Android & Cross-Platform Mobile Apps 2
K Programme für Handy erstellen Android & Cross-Platform Mobile Apps 3
K Handy Menüprogrammierung Android & Cross-Platform Mobile Apps 4
F Per Java zu Handy connecten Android & Cross-Platform Mobile Apps 5
J Handy-Spiel auf PC ausführen Android & Cross-Platform Mobile Apps 11
M Java-Programme für Handy auf Desktop-PC ausführen Android & Cross-Platform Mobile Apps 4
W JAVA2ME-Game von Handy (V300) auf Pc runterladen?? Android & Cross-Platform Mobile Apps 4
T Für Handy Game die Sprache umschreiben? Android & Cross-Platform Mobile Apps 24
M java game für handy mit grahi. oberfläche Android & Cross-Platform Mobile Apps 1
M Welches Siemens Handy? Android & Cross-Platform Mobile Apps 8
S Problem auf dem Handy Android & Cross-Platform Mobile Apps 3
B Kann man bei Nokia-Handy's über Java die IR ansteuern? Android & Cross-Platform Mobile Apps 6
B Erfahrungen mit Middlets?(Handy-Applets)? Android & Cross-Platform Mobile Apps 2
E Handy Java Anwendungen Android & Cross-Platform Mobile Apps 3
missy72 Kotlin SSH Verbindung mit JSch Android & Cross-Platform Mobile Apps 5
J Android VPN Verbindung herstellen? Android & Cross-Platform Mobile Apps 4
B Android TCP-Verbindung zum Server über welche Prozess auslagerung nutzen? Android & Cross-Platform Mobile Apps 1
M Problem bei Werteübergabe, MSQL verbindung Android & Cross-Platform Mobile Apps 3
H WIFI, Bluetooth und NFC Verbindung überwachen Android & Cross-Platform Mobile Apps 1
H Android 3G TCP Socket Verbindung zum PC durch NAT Android & Cross-Platform Mobile Apps 8
T Android MSSQL Verbindung herstellen - Android Studio Android & Cross-Platform Mobile Apps 2
M Android Server-Client-Verbindung in Android-App mit Sockets aufbauen Android & Cross-Platform Mobile Apps 5
W Android HTTPS-Verbindung mit Client-Authentifizierung Android & Cross-Platform Mobile Apps 0
R Socket Verbindung AsycTask Android & Cross-Platform Mobile Apps 5
F Android USB Verbindung zu Windows Programm Android & Cross-Platform Mobile Apps 3
U Android Https-Verbindung Android & Cross-Platform Mobile Apps 2
K Java ME Bluetooth verbindung parameter Android & Cross-Platform Mobile Apps 3
N Java ME Server-Client Verbindung über Wifi Android & Cross-Platform Mobile Apps 6
A Problem mit HTTP- Verbindung Android & Cross-Platform Mobile Apps 4
N Blutooz-Verbindung ... ich schaffs nicht Android & Cross-Platform Mobile Apps 5
F Server - Client Verbindung mit Java ME Android & Cross-Platform Mobile Apps 3
G Bluetooth Verbindung Android & Cross-Platform Mobile Apps 2
O Bluetooth Verbindung zwischen 2 Handys Android & Cross-Platform Mobile Apps 5
K HTTP-Verbindung mit J2ME.... Android & Cross-Platform Mobile Apps 2

Ähnliche Java Themen

Neue Themen


Oben