Commit 445c1e85e6fa0d88ffa9a6cf74802d338a51e784

Authored by Imanol-Mikel Barba Sabariego
1 parent 36b69b28

wifi sleep

src/com/upc/pbe/upcnews/MainActivity.java
@@ -36,8 +36,26 @@ public class MainActivity extends Activity implements OnClickListener { @@ -36,8 +36,26 @@ public class MainActivity extends Activity implements OnClickListener {
36 buttonDescarrega.setOnClickListener(this); 36 buttonDescarrega.setOnClickListener(this);
37 showText = (TextView) findViewById(R.id.textViewXml); 37 showText = (TextView) findViewById(R.id.textViewXml);
38 showRoute = (TextView) findViewById(R.id.textViewRoute); 38 showRoute = (TextView) findViewById(R.id.textViewRoute);
39 -  
40 this.getUrl(); 39 this.getUrl();
  40 +
  41 + new Thread() {
  42 + public void run() {
  43 + //Wifi Info
  44 + for (int i = 0; i < 10; i++) {
  45 + wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
  46 + WifiInfo info = wifi.getConnectionInfo();
  47 + int speed = info.getLinkSpeed();
  48 + String str = "Speed: " + speed;
  49 + Log.d(TAG, str);
  50 + try {
  51 + this.sleep(5000);
  52 + } catch (InterruptedException e) {
  53 + e.printStackTrace();
  54 + }
  55 + }
  56 + }
  57 + }.start();
  58 +
41 } 59 }
42 60
43 public boolean onCreateOptionsMenu(Menu menu) { 61 public boolean onCreateOptionsMenu(Menu menu) {
@@ -55,12 +73,7 @@ public class MainActivity extends Activity implements OnClickListener { @@ -55,12 +73,7 @@ public class MainActivity extends Activity implements OnClickListener {
55 public void onClick(View v) { 73 public void onClick(View v) {
56 Log.d(TAG, "onClicked"); 74 Log.d(TAG, "onClicked");
57 75
58 - //Wifi Info  
59 - wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);  
60 - WifiInfo info = wifi.getConnectionInfo();  
61 - int speed = info.getLinkSpeed();  
62 - String str = "Speed: "+speed;  
63 - Log.d(TAG, str); 76 +
64 77
65 this.descarregar(); 78 this.descarregar();
66 ((UpcApp) getApplication()).setDesc(html); 79 ((UpcApp) getApplication()).setDesc(html);
@@ -72,7 +85,6 @@ public class MainActivity extends Activity implements OnClickListener { @@ -72,7 +85,6 @@ public class MainActivity extends Activity implements OnClickListener {
72 Descarrega d = new Descarrega(this.getUrl(), file, folder); 85 Descarrega d = new Descarrega(this.getUrl(), file, folder);
73 Toast.makeText(this, "Download succesfull", Toast.LENGTH_LONG).show(); 86 Toast.makeText(this, "Download succesfull", Toast.LENGTH_LONG).show();
74 html = (String) d.doInBackground(); 87 html = (String) d.doInBackground();
75 -  
76 } 88 }
77 89
78 public boolean onOptionsItemSelected(MenuItem item) { 90 public boolean onOptionsItemSelected(MenuItem item) {