Netzsteckdose über App schalten

  • Antworten:1
Herbert Manger
  • Forum-Beiträge: 1

01.10.2012, 11:55:35 via Website

Hallo,
ich möchte eine Netzsteckdose über eine App ein- bzw. auschalten können.
Hierzu habe ich zwei Schaltflächen erstellt und einen Link nach folgendem Format geschaltet.
ip-adresse/r?b=1&r=0&s=0
Das klappt auch so weit ... nur wird eben dann die HTML-Oberfläche der Steckdose auch angezeigt
Ich möchte aber, dass die beiden Schaltflächen auf der Anzeige bleiben.


b2.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
Intent i2 = new Intent(Intent.ACTION_VIEW, Uri.parse("http://DNS.no-ip.info:1200/r?b=1&r=0&s=0"));
startActivity(i2);
}
});

Kann mir jemand bitte sagen wie das geht?

Antworten
Gelöschter Account
  • Forum-Beiträge: 82

01.10.2012, 17:38:55 via Website

1public static String httpurlconnection(String reqUrl) {
2
3 try {
4 HttpURLConnection con = (HttpURLConnection) new URL(reqUrl).openConnection();
5
6 if (con.getResponseCode() == HttpURLConnection.HTTP_OK) {
7 Log.w("httpurlconnection","httpurlconnection/response:\n "+inputStreamToString(con.getInputStream()));
8 return inputStreamToString(con.getInputStream());
9 } else {
10 Log.w("httpurlconnection","httpurlconnection/error: HTTP not OK");
11 return "error";
12 }
13
14 } catch (MalformedURLException e) {
15 Log.w("httpurlconnection","httpurlconnection/error: MalformedURLException");
16 return "error";
17 } catch (IOException e) {
18 Log.w("httpurlconnection","httpurlconnection/error: IOException");
19 return "error";
20 }
21
22 }

So wird die Seite "angefunkt". Man muss ja die Rückgabe nicht unbedingt verwerten.

Leider zerstört das Forum meine Einrückung.:angry:

Antworten