0
我想要做的是在我的Android應用程序中,當我按下按鈕時,我想打開此網頁(在代碼中)並按下「打開」按鈕。我將如何在Java/Android中完成此操作?打開網頁並點擊Android中的按鈕
<html>
<head>
<meta charset="UTF-8" />
<title>Webpage</title>
</head>
<?php
if (isset($_POST['OPEN']))
{
exec("<link here>");
}
?>
<form method="post">
<button name="OPEN"> Open</button><br>
</form>
</html>
我對Android的代碼,解決了這個 - 感謝很大的提示@his
String RPI_IP = "http://192.172.26.1/index.php";
String param = "OPEN=";
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(RPI_IP);
try {
// Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("OPEN", ""));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
這只是你上面看到的代碼 - HTML + PHP。有沒有代碼示例?感謝您的快速回答 – ForeverLearning
不要忘了,想通了......發佈代碼很快 – ForeverLearning