This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
byte[] dammidatibyteridotti(double lat, double lon, double pre) { | |
byte[] ritorno; | |
String _latitudine = String.format(Locale.ENGLISH,"%.5f", lat); | |
if(_latitudine.length() < 8) { _latitudine = "0" + _latitudine; } | |
String _longitudine = String.format(Locale.ENGLISH,"%.5f", lon); | |
if(_longitudine.length() < 8) { _longitudine = "0" + _longitudine; } | |
String _precisione = String.format(Locale.ENGLISH, "%d", (int) pre); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
byte[] concat(byte[]...arrays) | |
{ | |
// Determine the length of the result array | |
int totalLength = 0; | |
for (byte[] array : arrays) { | |
totalLength += array.length; | |
} | |
// create the result array | |
byte[] result = new byte[totalLength]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static double calculateDistance(float txPower, double rssi) { | |
if (rssi == 0) { | |
return -1.0; // if we cannot determine distance, return -1. | |
} | |
double ratio = rssi * 1.0 / txPower; | |
if (ratio < 1.0) { | |
return Math.pow(ratio, 10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String byteArrayToHex(byte[] a) { | |
StringBuilder sb = new StringBuilder(a.length * 2); | |
for(byte b: a) | |
sb.append(String.format("%02x", b)); | |
return sb.toString(); | |
} | |
public static byte[] hexStringToByteArray(String s) { | |
int len = s.length(); | |
byte[] data = new byte[len/2]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private String wordwrap(String testo, int dimensione ) { | |
String temp_testo; | |
temp_testo = Html.fromHtml(testo, Html.FROM_HTML_MODE_LEGACY).toString(); | |
StringBuilder sb = new StringBuilder(temp_testo); | |
int i = 0; | |
while (i + dimensione < sb.length() && (i = sb.lastIndexOf(" ", i + dimensione)) != -1) { | |
sb.replace(i, i + 1, "\n"); | |
} | |
return sb.toString(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Bitmap icogen(int tipo, Context context) { | |
String testo = ""; | |
IconGenerator icg = new IconGenerator( context ); | |
icg.setBackground(ContextCompat.getDrawable(context, R.drawable.amu_bubble_mask ) ); | |
if (tipo == 1) { | |
icg.setColor( R.color.nero ); | |
icg.setStyle( IconGenerator.STYLE_GREEN ); | |
testo = "Varco"; | |
} else if (tipo == 2) { | |
icg.setColor( R.color.bianco ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static boolean findBinary(String binaryName) { | |
boolean found = false; | |
String[] places = { "/sbin/", "/system/bin/", "/system/xbin/", | |
"/data/local/xbin/", "/data/local/bin/", | |
"/system/sd/xbin/", "/system/bin/failsafe/", "/data/local/" }; | |
for (String where : places) { | |
if (new File(where + binaryName).exists()) { | |
found = true; | |
break; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean AddressReachable(String hostUrl) { | |
try { | |
URL url = new URL(hostUrl); | |
final HttpURLConnection urlc = (HttpURLConnection) url.openConnection(); | |
urlc.setRequestProperty("User-Agent", "Android Application"); | |
urlc.setRequestProperty("Connection", "close"); | |
urlc.setConnectTimeout(10 * 1000); | |
urlc.connect(); | |
// Fix per connessione con certificato | |
if (urlc.getResponseCode() == 200 || urlc.getResponseCode() == 403) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FragmentService { | |
private final FragmentManager _fragmentManager; | |
public FragmentService(FragmentManager fragmentManager) { | |
_fragmentManager = fragmentManager; | |
} | |
public void loadFragment(int id, Fragment fragment, String name){ | |
FragmentTransaction fragmentTransaction = _fragmentManager.beginTransaction(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
txtmacmacaddress.addTextChangedListener(new TextWatcher() { | |
String mPreviousMac = null; | |
@Override | |
public void afterTextChanged(Editable arg0) { | |
} | |
@Override | |
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { | |
} |
OlderNewer