Código Para Corregir La Versión Del Sistema

Embed Size (px)

Citation preview

  • 8/11/2019 Cdigo Para Corregir La Versin Del Sistema

    1/7

    Cdigo para corregir la versin del sistema.

    buildscript {

    repositories {

    mavenCentral()

    }

    dependencies {

    classpath 'com.android.tools.build:gradle:0.12.+'

    }

    apply plugin: 'android'

    android {

    compileSdkVersion 19

    buildToolsVersion '19.1.0'

    defaultConfig {

    minSdkVersion 7

    targetSdkVersion 10

    versionCode 1

    versionName "1.0"

    }

    buildTypes {

    debug {

    runProguard true

    }

    }

    }

  • 8/11/2019 Cdigo Para Corregir La Versin Del Sistema

    2/7

    dependencies {

    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile 'com.android.support:appcompat-v7:20.+'

    compile 'com.android.support:support-v4:20.+'

    }

  • 8/11/2019 Cdigo Para Corregir La Versin Del Sistema

    3/7

    Cdigo para detectar datos y wifi

    En algunos casos puede ser interesante conocer datos de la red que est usando. Las

    clasesTelephonyManageryWifiManagernos facilitan conocer esta informacin.

    El siguiente cdigo hace uso de ellas para averiguar si la wifi est activada (y sus datos) as

    como informacin sobre la red telefnica que esta usando como el operador (MCC/MNC,nombre y pas) o tipo de red.

    Tambin configura un botn que abre la configuracin wifi del sistema.

    package

    org.francho.test.network;

    import

    android.app.Activity;

    import

    android.content.Context;

    import

    android.content.Intent;

    import

    android.net.wifi.WifiInfo;

    importandroid.net.wifi.WifiManager; importandroid.os.Bundle;importandroid.provider.Settings;importandroid.telephony.TelephonyManager; importandroid.view.View;importandroid.view.View.OnClickListener; importandroid.widget.Button;importandroid.widget.TextView;

    publicclassNetworkTest extendsActivity {privateTextView tInfo;

    /** Called when the activity is first created. */

    @OverridepublicvoidonCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.main);

    // Al pulsar el boton lanzamos la configuracin de wifiButton configWifi = (Button) findViewById(R.id.botonConfigWifi);configWifi.setOnClickListener(new OnClickListener() {

    @Override

    public

    void

    onClick(View v) {

    Intent i = newIntent(Settings.ACTION_WIFI_SETTINGS); startActivity(i);

    }

    });

    // Campo de texto donde mostraremos la infotInfo = (TextView) findViewById(R.id.textoInfo);

    }

    @OverridepublicvoidonStart() {

    http://developer.android.com/reference/android/telephony/TelephonyManager.htmlhttp://developer.android.com/reference/android/telephony/TelephonyManager.htmlhttp://developer.android.com/reference/android/telephony/TelephonyManager.htmlhttp://developer.android.com/reference/android/net/wifi/WifiManager.htmlhttp://developer.android.com/reference/android/net/wifi/WifiManager.htmlhttp://developer.android.com/reference/android/net/wifi/WifiManager.htmlhttp://es.wikipedia.org/wiki/MCC/MNChttp://es.wikipedia.org/wiki/MCC/MNChttp://es.wikipedia.org/wiki/MCC/MNChttp://es.wikipedia.org/wiki/MCC/MNChttp://developer.android.com/reference/android/net/wifi/WifiManager.htmlhttp://developer.android.com/reference/android/telephony/TelephonyManager.html
  • 8/11/2019 Cdigo Para Corregir La Versin Del Sistema

    4/7

    super.onStart();

    String info = "Wifi"+ "\n";

    // Comprobamos si la wifi est activada o noWifiManager wifiMan = (WifiManager) getSystemService(Context.WIFI_SERVICE)

    if(wifiMan.isWifiEnabled()) {info +="\t"+ "Estado: activa "+"\n";

    WifiInfo wifi = wifiMan.getConnectionInfo();info +="\t"+ wifi.toString().replace(", ", "\n\t");

    } else{info +="\t"+ "Estado: inactiva"+ "\n";

    }

    // Averiguamos datos de la red telefnicaTelephonyManager tlfMan = (TelephonyManager)

    getSystemService(Context.TELEPHONY_SERVICE);

    info +="\n"+ "Telefona: "+ "\n";info +="\t"+ "Operador (MCC+MNC): "+ tlfMan.getNetworkOperator() + "\n";info +="\t"+ "Nombre Operador: "+ tlfMan.getNetworkOperatorName() + "\n";info +="\t"+ "N Pas: "+ tlfMan.getNetworkCountryIso() + "\n";

    switch(tlfMan.getNetworkType()) {caseTelephonyManager.NETWORK_TYPE_GPRS:

    info +="\t"+ "Tipo red: GPRS"+ "\n";break;

    case

    TelephonyManager.NETWORK_TYPE_HSDPA:

    info +="\t"

    + "Tipo red: HSDPA"

    + "\n";

    break;

    case

    TelephonyManager.NETWORK_TYPE_HSPA:info +="\t"+ "Tipo red: HSPA"+ "\n";

    break;caseTelephonyManager.NETWORK_TYPE_UMTS:

    info +="\t"+ "Tipo red: UMTS"+ "\n";break;

    caseTelephonyManager.NETWORK_TYPE_UNKNOWN: info +="\t"

    + "Tipo red: desconocida "

    + "\n";

    break;

    default:

    info +="\t"

    + "Tipo red: otra ("

    + tlfMan.getNetworkType() + ")\n";

    }

    tInfo.setText(info);}

    }

    Linea telefnica

    privateStringgetPhoneNumber(){TelephonyManager mTelephonyManager;

  • 8/11/2019 Cdigo Para Corregir La Versin Del Sistema

    5/7

    mTelephonyManager =(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);

    returnmTelephonyManager.getLine1Number();}

    Varias lneas

    import android.app.Activity;

    import android.content.Context;

    import android.content.Intent;

    import android.content.SharedPreferences;

    import android.content.SharedPreferences.Editor;

    import android.os.Bundle;

    import android.telephony.TelephonyManager;

    import android.util.Log;

    import android.widget.Toast;

    import android.provider.Settings.Secure;

    //Android Manisfest

    //

    //Requires READ_PHONE_STATE uses-permission

    public static String CelularDadosGerais()

    {

    TelephonyManager tm;

    tm = (TelephonyManager)getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);

    //SimCard

    int simState = tm.getSimState();String SimStateStatus = "";

    switch (simState)

    {

    case (TelephonyManager.SIM_STATE_ABSENT):

    SimStateStatus = "SimState: ABSENT";

    break;

    case (TelephonyManager.SIM_STATE_NETWORK_LOCKED):

    SimStateStatus = "SimState: NETWORK_LOCKED";

    break;

    case (TelephonyManager.SIM_STATE_PIN_REQUIRED):

    SimStateStatus = "SimState: PIN_REQUIRED";

    break;

    case (TelephonyManager.SIM_STATE_PUK_REQUIRED):

    SimStateStatus = "SimState: PUK_REQUIRED";

    break;

    case (TelephonyManager.SIM_STATE_UNKNOWN):

    SimStateStatus = "SimState: UNKNOWN";

    break;

    case (TelephonyManager.SIM_STATE_READY):

    SimStateStatus = "SimState: READY";

    break;

  • 8/11/2019 Cdigo Para Corregir La Versin Del Sistema

    6/7

    }

    //Numero da Linha 1

    String NumCelular1 = tm.getLine1Number();

    //Numero da Linha 2

    //String NumCelular2 = tm.getLine2Number();

    //Retorna o ID nico dispositivo, por exemplo, o IMEI para o GSM eo MEID ou ESN para celulares CDMA.

    String IMEI = tm.getDeviceId();

    //Get SIM Serial Number - Retorna o nmero de srie do SIM, se for o caso.

    String SIMSerial = tm.getSimSerialNumber();

    //Retorna a identificao de assinante original, por exemplo, o IMSI para um telefone GSM.

    String SubscriberId = tm.getSubscriberId();

    //Get SIM Country ISO Code - Retorna o cdigo do pas ISO equivalente para o cdigo de pas do fornecedor

    SIM.

    String SIMCountryISO = tm.getSimCountryIso();

    //Retorna o nmero da verso do software para o dispositivo, por exemplo, o IMEI / SV para telefones GSM.

    String SoftwareVersion = tm.getDeviceSoftwareVersion();

    //Get Network Country ISO Code - Retorna o cdigo de pas ISO equivalente do MCC do atual operador

    registado (Country Code Mobile).

    String NetworkCountryISO = tm.getNetworkCountryIso();

    //Retorna o nome numrico (MCC + MNC) do atual operador registado.

    String NetworkOperator = tm.getNetworkOperator();

    //Retorna o nome alfabtica do atual operador registado

    String NetworkOperatorName = tm.getNetworkOperatorName();

    //Retorna o MCC + MNC (cdigo do pas + cdigo de rede mvel celular) do provedor do SIM.

    String Operator = tm.getSimOperator();

    //Retorna o nome do provedor de servio (SPN).

    String OperatorName = tm.getSimOperatorName();

    //Recupera o identificador alfabtico associado com o nmero de correio de voz.

    String VoiceMailAlphaTag = tm.getVoiceMailAlphaTag();

    //Retorna o nmero de correio de voz.

    String VoiceMailNumber = tm.getVoiceMailNumber();

    //Resultado

    String RetornoNumCelular = NumCelular1 +"; "+ IMEI +"; "+ SIMSerial +"; "+ SubscriberId +"; "+

    SIMCountryISO +"; "+ SoftwareVersion +"; "+ NetworkCountryISO +"; "+ NetworkOperator +"; "+

    NetworkOperatorName +"; "+ Operator +"; "+ OperatorName +"; "+ VoiceMailAlphaTag +"; "+

    VoiceMailNumber +"; "+ SimStateStatus;

    return(RetornoNumCelular);

  • 8/11/2019 Cdigo Para Corregir La Versin Del Sistema

    7/7