Commit 625f7d457c59077999b06aec272e56b9913497de

Authored by Imanol-Mikel Barba Sabariego
1 parent 71234b1a

Wifi Status added

AndroidManifest.xml
... ... @@ -8,6 +8,7 @@
8 8 android:targetSdkVersion="10" />
9 9 <uses-permission android:name="android.permission.INTERNET"/>
10 10 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  11 + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
11 12  
12 13  
13 14 <application
... ...
src/com/upc/pbe/upcnews/MainActivity.java
1 1 package com.upc.pbe.upcnews;
2 2  
3 3 import android.app.Activity;
  4 +import android.content.Context;
4 5 import android.content.Intent;
  6 +import android.net.wifi.WifiInfo;
  7 +import android.net.wifi.WifiManager;
5 8 import android.os.Bundle;
6 9 import android.util.Log;
7 10 import android.view.Menu;
... ... @@ -15,6 +18,7 @@ import android.widget.Toast;
15 18 public class MainActivity extends Activity implements OnClickListener {
16 19 final static String TAG = "Main";
17 20 static String html;
  21 + WifiManager wifi;
18 22  
19 23 Directoris dir;
20 24 Button buttonDescarrega;
... ... @@ -50,6 +54,11 @@ public class MainActivity extends Activity implements OnClickListener {
50 54  
51 55 public void onClick(View v) {
52 56 Log.d(TAG, "onClicked");
  57 + wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
  58 + WifiInfo info = wifi.getConnectionInfo();
  59 + int speed = info.getLinkSpeed();
  60 + String str = "Speed: "+speed;
  61 + Log.d(TAG, str);
53 62 this.descarregar();
54 63 ((UpcApp) getApplication()).setDesc(html);
55 64 startActivity(new Intent(this, Directoris.class));
... ...
src/com/upc/pbe/upcnews/UpcApp.java
... ... @@ -11,7 +11,7 @@ public class UpcApp extends Application implements OnSharedPreferenceChangeListe
11 11  
12 12 final static String TAG = "Application";
13 13 SharedPreferences prefs;
14   - String defaultUrl = "10.0.2.100";
  14 + String defaultUrl = "imanolbarba.myftp.biz/PBE";
15 15 String url = null;
16 16 String desc;
17 17  
... ...