1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
public void OpenHc2() {
SharedPreferences sharedPrefs = PreferenceManager
.getDefaultSharedPreferences(this);
CharSequence PrefHcIP = sharedPrefs.getString("preHc2Ip","");
String Authorisation = (sharedPrefs.getString("prefUserName","")+ ":"+sharedPrefs.getString("preUserPassword",""));
String AppLogin1;
try {
AppLogin1 = android.util.Base64.encodeToString(Authorisation.getBytes("UTF-8"), android.util.Base64.DEFAULT);
Web client1 = new Web("http://"+PrefHcIP+"/api/callAction?deviceID=8&name=setValue&arg1=0");
client1.AddHeader("Connection", "Keep-Alive");
client1.AddHeader("Content-Type", "*/*");
client1.AddHeader("Authorization", "Basic YWRtaW46YWRtaW4=");
int duration = Toast.LENGTH_SHORT;
Context context1 = getApplicationContext();
Toast toast = Toast.makeText(context1, AppLogin1, duration);
toast.show();
try {
client1.Execute(RequestMethod.GET);
} catch (Exception e) {
e.printStackTrace();
}
} catch (UnsupportedEncodingException e1)
{
e1.printStackTrace();
}
} |