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 double CalcularDistancia(double origem_lat, double origem_lng, double destino_lat, double destino_lng) { | |
//Constante - Raio da terra em KM | |
const double r = 6371; | |
//Convertendo de graus para radianos | |
double x1 = (origem_lat * Math.PI) / 180; | |
double x2 = (destino_lat * Math.PI) / 180; | |
double y1 = (origem_lng * Math.PI) / 180; | |
double y2 = (destino_lng * Math.PI) / 180; |
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
import android.util.Log; | |
import javax.activation.*; | |
import javax.activation.DataSource; | |
import javax.mail.*; | |
import javax.mail.Session; | |
import javax.mail.internet.InternetAddress; | |
import javax.mail.internet.MimeBodyPart; | |
import javax.mail.internet.MimeMessage; | |
import javax.mail.internet.MimeMultipart; | |
import java.util.Date; |
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 hasConnection(Context context) { | |
try { | |
ConnectivityManager cm = (ConnectivityManager) | |
context.getSystemService(Context.CONNECTIVITY_SERVICE); | |
if (cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnected()) { | |
Log.i("hasConnection","Status de conexao 3G: " + cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).isConnected()); | |
return true; | |
} else if(cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected()){ | |
Log.i("hasConnection","Status de conexao Wifi: " + cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected()); | |
return true; |
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
//Formata o tempo em HH:MM | |
public static String formatToHourMinute(long timeInMinutes){ | |
int i = 0; | |
long minutes = timeInMinutes; | |
String formatedResult = ""; | |
if(minutes >= 60) { | |
i = (int) (minutes % 60); | |
if(minutes <= 9) |
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 unformatPhone(String phoneNumber) { | |
if (phoneNumber != null) { | |
while (phoneNumber.indexOf("+") > -1) { | |
phoneNumber = phoneNumber.replace("+55", ""); | |
} | |
phoneNumber = phoneNumber.replaceAll("-", ""); | |
phoneNumber = phoneNumber.replaceAll("\\(", ""); | |
phoneNumber = phoneNumber.replaceAll("\\)", ""); | |
phoneNumber = phoneNumber.replaceAll(" ", ""); |
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 UploadConnection extends Thread { | |
private String serverResponseMessage; | |
private int serverResponseCode; | |
private String urlServer; | |
private String pathToOurFile; | |
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 void generateLogCatFile(String filePath){ | |
StringBuilder sb = new StringBuilder(); | |
try { | |
String baseCommand = "logcat -d "; | |
baseCommand += " -v time " + Constants.LOG_TAG + ":V "; | |
baseCommand += " *:S "; | |
Process process = Runtime.getRuntime().exec(baseCommand); | |
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); |
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 int CONNECTION_TIMEOUT = 30000; | |
private static int WAIT_RESPONSE_TIMEOUT = 50000; | |
public static String doGet(String url) { | |
try { | |
URI uri = new URI(url); | |
HttpGet get = new HttpGet(uri); | |
HttpParams httpParameters = new BasicHttpParams(); |
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
import android.app.Activity; | |
import android.app.ProgressDialog; | |
import android.content.Intent; | |
import android.graphics.Bitmap; | |
import android.graphics.BitmapFactory; | |
import android.net.Uri; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.os.Message; | |
import android.util.Log; |
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 double CalcularDistancia(double origem_lat, double origem_lng, double destino_lat, double destino_lng) { | |
double x1 = origem_lat; | |
double x2 = destino_lat; | |
double y1 = origem_lng; | |
double y2 = destino_lng; | |
// Distancia entre os 2 pontos no plano cartesiano ( pitagoras ) | |
//double distancia = System.Math.Sqrt( System.Math.Pow( (x2 - x1), 2 ) + System.Math.Pow( (y2 - y1), 2 ) ); | |
// ARCO AB = c |
NewerOlder