Commit 445c1e85e6fa0d88ffa9a6cf74802d338a51e784
1 parent
36b69b28
wifi sleep
Showing
1 changed file
with
20 additions
and
8 deletions
src/com/upc/pbe/upcnews/MainActivity.java
... | ... | @@ -36,8 +36,26 @@ public class MainActivity extends Activity implements OnClickListener { |
36 | 36 | buttonDescarrega.setOnClickListener(this); |
37 | 37 | showText = (TextView) findViewById(R.id.textViewXml); |
38 | 38 | showRoute = (TextView) findViewById(R.id.textViewRoute); |
39 | - | |
40 | 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 | 61 | public boolean onCreateOptionsMenu(Menu menu) { |
... | ... | @@ -55,12 +73,7 @@ public class MainActivity extends Activity implements OnClickListener { |
55 | 73 | public void onClick(View v) { |
56 | 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 | 78 | this.descarregar(); |
66 | 79 | ((UpcApp) getApplication()).setDesc(html); |
... | ... | @@ -72,7 +85,6 @@ public class MainActivity extends Activity implements OnClickListener { |
72 | 85 | Descarrega d = new Descarrega(this.getUrl(), file, folder); |
73 | 86 | Toast.makeText(this, "Download succesfull", Toast.LENGTH_LONG).show(); |
74 | 87 | html = (String) d.doInBackground(); |
75 | - | |
76 | 88 | } |
77 | 89 | |
78 | 90 | public boolean onOptionsItemSelected(MenuItem item) { | ... | ... |