Entradas

Mostrando las entradas etiquetadas como Android

Obtener código de dispositivo

String codigoEquipo = Settings . Secure . getString ( getContentResolver (), Settings . Secure . ANDROID_ID ). toUpperCase ();

Subir proyecto al repositorio existente en Bitbucket

Abrir consola y ubicarse en la ruta donde esta ubicada el proyecto 1.- git init 2.- git add . 3.- git commit -m "Primer commit" 4.- git remote add origin https://nombre_usuario@bitbucket.org/nombre_usuario/nombre_proyecto.git 5.- git push -u origin --all Referencia: https://confluence.atlassian.com/bitbucket/add-unversioned-code-to-a-repository-877177133.html

Migrar JKS a PKCS12

Para migrar a PKCS12 seguir los siguientes pasos: Ubicar en la carpeta BIN de JAVA Ejecutar la siguiente linea de código indicando la ruta del jks generado por android studio keytool -importkeystore -srckeystore D:\bolaina.jks -destkeystore D:\bolaina.jks -deststoretype pkcs12 Lo que realizara sera reemplazar el archivo jks ya generado e incluira el PKCS12, esto servirá para poder publicarlo.
InputType none text textCapCharacters textCapWords textCapSentences textAutoCorrect textAutoComplete textMultiLine textImeMultiLine textNoSuggestions textUri textEmailAddress textEmailSubject textShortMessage textLongMessage textPersonName textPostalAddress textPassword textVisiblePassword textWebEditText textFilter textPhonetic textWebEmailAddress textWebPassword number numberSigned numberDecimal numberPassword phone datetime date time Explicación:  http://developer.android.com/reference/android/widget/TextView.html#attr_android:inputType
OBTENER IMEI DE UN DISPOSITIVO ANDROID final TelephonyManager mngr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); String imei = mngr.getDeviceId() != null ? mngr.getDeviceId() : "000000000000000"; OBTENER MAC ADDRESS DE UN DISPOSITIVO ANDROID WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); WifiInfo wInfo = wifiManager.getConnectionInfo(); String macAddress = wInfo.getMacAddress() != null ? wInfo.getMacAddress().toUpperCase() : ""; OBTENER ID DEL DISPOSITIVO ANDROID final TelephonyManager mngr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); imei = Secure.getString(getContentResolver(), Secure.ANDROID_ID);
GPS DESACTIVADO public static void alertaGpsDesactivado(final Context context){ final AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.setTitle(Constantes.MENSAJE); alertDialog.setMessage(Constantes.MENSAJE_GPS_DESACTIVADO); alertDialog.setIcon(R.drawable.info_48x48); alertDialog.setButton("Aceptar", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { context.startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS)); alertDialog.dismiss(); } }); alertDialog.show(); } Util.alertaGpsDesactivado(this);
DISTANCIA ENTRE DOS PUNTOS GEO-REFERENCIADOS public static double distanciaCoord(double lat1, double lng1, double lat2, double lng2) {         //double radioTierra = 3958.75;//en millas         //double radioTierra = 6371;//en kilómetros double radioTierra = 6371000;//en metros         double dLat = Math.toRadians(lat2 - lat1);         double dLng = Math.toRadians(lng2 - lng1);         double sindLat = Math.sin(dLat / 2);         double sindLng = Math.sin(dLng / 2);         double va1 = Math.pow(sindLat, 2) + Math.pow(sindLng, 2) * Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2));         double va2 = 2 * Math.atan2(Math.sqrt(va1), Math.sqrt(1 - va1));         double distancia = radioTierra * va2;            return round(distancia, 8); } public s...
MANEJO DE IMAGENES EN ANDROID public static String bitmapToBase64(Bitmap bitmap) {     ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();     bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);     byte[] byteArray = byteArrayOutputStream .toByteArray();     return Base64.encodeToString(byteArray, Base64.DEFAULT); } public static Bitmap base64ToBitmap(String b64) {     byte[] imageAsBytes = Base64.decode(b64.getBytes(), Base64.DEFAULT);     return BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length); }
REEMPLAZAR CARACTERES ESPECIALES public static String reemplazarCarateresEspeciales(String cadena){ //String cadena1 = "Sé te n°ota que est|as eno'jado N° 1234"; String valor = cadena != null ? cadena : ""; valor = valor.replaceAll("[á|à|Á|À]", "A"); valor = valor.replaceAll("[é|è|É|È]", "E"); valor = valor.replaceAll("[í|ì|Í|Ì]", "I"); valor = valor.replaceAll("[ó|ò|Ó|Ò]", "O"); valor = valor.replaceAll("[ú|ù|Ú|Ù]", "U"); valor = valor.replaceAll("[ñ|Ñ]", "N"); //valor = valor.replaceAll("['|||°]", ""); valor = valor.replaceAll("[^-a-zA-Z0-9$ ]+",""); //System.out.println("cadena : " + cadena2); return valor; }
REDIMENSIONAR IMAGENES public static Bitmap redimensionarImagenMaximo(Bitmap mBitmap, String usuario, String imei){ try{ //Redimensionamos int width = mBitmap.getWidth(); int height = mBitmap.getHeight(); float scaleWidth = ((float) Constantes.RESOLUCION_VGA_WIDTH) / width; float scaleHeight = ((float) Constantes.RESOLUCION_VGA_HEIGHT) / height; // create a matrix for the manipulation Matrix matrix = new Matrix(); // resize the bit map matrix.postScale(scaleWidth, scaleHeight); // recreate the new Bitmap return Bitmap.createBitmap(mBitmap, 0, 0, width, height, matrix, false); }catch(Exception e){ LogCustom.error(Util.class.getClass().getName(), usuario, imei, e); return null; } } public static final int RESOLUCION_VGA_WIDTH = 640; public static final int RESOLUCION_VGA_HEIGHT = 480;
OBTENER FECHA Y HORA DEL GPS public static String fechaHoraGPS(Long time) { String fechaHora = ""; GregorianCalendar gcal = new //GregorianCalendar(TimeZone.getTimeZone("UTC"));     GregorianCalendar(TimeZone.getTimeZone("America/Lima"));     gcal.setTimeInMillis(time);         String dia = StringUtils.leftPad(String.valueOf(gcal.get(GregorianCalendar.DAY_OF_MONTH)), 2, "0");     String mes = StringUtils.leftPad(String.valueOf(gcal.get(GregorianCalendar.MONTH) + 1), 2, "0");     String anio = String.valueOf(gcal.get(GregorianCalendar.YEAR));     String hora = StringUtils.leftPad(String.valueOf(gcal.get(GregorianCalendar.HOUR_OF_DAY)), 2, "0");     String minuto = StringUtils.leftPad(String.valueOf(gcal.get(GregorianCalendar.MINUTE)), 2, "0");     String segundo = StringUtils.leftPad(String.valueOf(gcal.get(GregorianCalendar.SECOND)), 2, "0");       ...
OBTENER FECHA Y HORA public static String obtenerFechaHora(){ Date date = new Date(); //Caso 1: obtener la hora y salida por pantalla con formato: DateFormat hourFormat = new SimpleDateFormat("HH:mm:ss"); //System.out.println("Hora: "+hourFormat.format(date)); //Caso 2: obtener la fecha y salida por pantalla con formato: DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); //System.out.println("Fecha: "+dateFormat.format(date)); //Caso 3: obtenerhora y fecha y salida por pantalla con formato: DateFormat hourdateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); //System.out.println("Fecha y Hora : " + hourdateFormat.format(date)); return hourdateFormat.format(date); }
VERIFICA SI EL DISPOSITIVO CUENTA CON INTERNET public static boolean isOnline(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(context.CONNECTIVITY_SERVICE); NetworkInfo netinfo = cm.getActiveNetworkInfo(); if(netinfo != null && netinfo.isConnected()) { return true; } return false; }