Application use: I am creating a connection between a tablet and a desktop. This tablet will send command to my desktop that my java app will then interpret and do accordingly. One of these features I would like to include is controlling Skype. Such as focusing on it. Switching chats. Initiating call. Sending message. ect. But I can't seem get the URI api to work. (This is the only known api that will allow me to initiate calls and chats, so if you know of any other. Please do tell.)
I am not sure If I am doing it right being that this is my first time using a URI ever. This is what I have using
import java.net.URI
public void uriTest(){
try{
URI uri = URI.create("skype:echo123?call");
}catch(Exception ex){
ex.printStackTrace();
}
}
What am I missing? I know it is probably a lot. Is there some sort of way to implement it. Or when you call .create() does it automatically do it for you?
Any help or clarification will be greatly appreciated.
Your code constucted an URI
and now you have one, nothing more, nothing less. An URI
is - as the name "Universsal Resource Identifier" says - just an identifier.
What you probably want to do is establish a connection to a location identified by that URI
. So you need a special identifier, a so-called "Universal Resource Locator" or URL
:
URL url = new URL("skype:echo123?call");
Still nothing happening since we only defined a location. Next you have to connect
to it:
URLConnection conn = url.openConnection();
Now you got an URLConnection
-object (in this case a HttpURLConnection
) and you can operate with it: post data, read responses etc. Read up on the API of java.net.HttpURLConnection
to learn more.