From 445c1e85e6fa0d88ffa9a6cf74802d338a51e784 Mon Sep 17 00:00:00 2001 From: Equip de Desenvolupadors de PBE Date: Thu, 29 Nov 2012 12:13:05 +0000 Subject: [PATCH] wifi sleep --- src/com/upc/pbe/upcnews/MainActivity.java | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/com/upc/pbe/upcnews/MainActivity.java b/src/com/upc/pbe/upcnews/MainActivity.java index 1127402..7767cc5 100644 --- a/src/com/upc/pbe/upcnews/MainActivity.java +++ b/src/com/upc/pbe/upcnews/MainActivity.java @@ -36,8 +36,26 @@ public class MainActivity extends Activity implements OnClickListener { buttonDescarrega.setOnClickListener(this); showText = (TextView) findViewById(R.id.textViewXml); showRoute = (TextView) findViewById(R.id.textViewRoute); - this.getUrl(); + + new Thread() { + public void run() { + //Wifi Info + for (int i = 0; i < 10; i++) { + wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); + WifiInfo info = wifi.getConnectionInfo(); + int speed = info.getLinkSpeed(); + String str = "Speed: " + speed; + Log.d(TAG, str); + try { + this.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + }.start(); + } public boolean onCreateOptionsMenu(Menu menu) { @@ -55,12 +73,7 @@ public class MainActivity extends Activity implements OnClickListener { public void onClick(View v) { Log.d(TAG, "onClicked"); - //Wifi Info - wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); - WifiInfo info = wifi.getConnectionInfo(); - int speed = info.getLinkSpeed(); - String str = "Speed: "+speed; - Log.d(TAG, str); + this.descarregar(); ((UpcApp) getApplication()).setDesc(html); @@ -72,7 +85,6 @@ public class MainActivity extends Activity implements OnClickListener { Descarrega d = new Descarrega(this.getUrl(), file, folder); Toast.makeText(this, "Download succesfull", Toast.LENGTH_LONG).show(); html = (String) d.doInBackground(); - } public boolean onOptionsItemSelected(MenuItem item) { -- libgit2 0.22.2