0

我正在寻找一个 android 应用程序,它将调用我在我的计算机上制作的一个有趣的小脚本。当我在网络浏览器中打开脚本时,计算机将运行“哔”命令。我将如何从 android 应用程序中执行此操作,以便当我按下按钮时它会调用网站并发出哔哔声我的电脑?我试过这个,但它似乎对我不起作用。

HttpGet httpget = new HttpGet(
    "http://www.blah.com/beep.php");

更多信息:我在服务器上运行的代码:

beeping!
<?php
shell_exec("beep -f 2000 -r 3 -l 100 -d 20"); ?>

我正在运行具有调用 beep 方法的按钮的应用程序。

公共类 MainActivity 扩展 Activity {

@Override
  protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);
 }

@Override
 public boolean onCreateOptionsMenu(Menu menu) {
 // Inflate the menu; this adds items to the action bar if it is present.
 getMenuInflater().inflate(R.menu.main, menu);
 return true;
} //here is the error that says i need to remove this token

new Thread(new Runnable() {
  public void run(){
    try{
      HttpClient httpclient = new DefaultHttpClient();

      HttpGet httpget = new HttpGet(
        "http://www.blah.com/beep.php");
    }
    catch(Exception e){
      throw e;
  }}
}).start();
} //here is the error to insert } to complete classbody
4

1 回答 1

1
new Thread(new Runnable() {
public void run() {
    try {
    HttpClient httpclient = new DefaultHttpClient();

    HttpGet httpget = new HttpGet(
        "http://www.blah.com/beep.php");
    HttpResponse response = httpclient.execute(httpget);
    } catch(Exception x) {
        ...
    }}
}).start();
于 2013-05-20T20:44:09.423 回答