Skip to content

Instantly share code, notes, and snippets.

View olcayertas's full-sized avatar

Olcay Ertaş olcayertas

View GitHub Profile
@olcayertas
olcayertas / CalculateQiblaAngle.java
Last active April 25, 2017 00:58
Calculates qibla angel acording to curren location.
private static final double KAABA_LONGITUDE = 39.826228;
private static final double KAABA_LATITUDE = 21.422305;
private double getQiblaAngele(double myLatitude, double myLongitude) {
double sinMyLoMinusQLo = Math.sin(myLongitude - KAABA_LONGITUDE);
double cosMyLat = Math.cos(myLatitude);
double tanQLat = Math.tan(KAABA_LATITUDE);
double sinMyLat = Math.sin(myLatitude);
double cosMyLoMinusQlo = Math.cos(myLongitude - KAABA_LONGITUDE);
@olcayertas
olcayertas / GetInstalledApplicationList
Last active September 11, 2015 12:21
Returns the installed application list as List<ApplicationInfo> on the device.
/**
* Returns the installed application list on the device.
* @param activity Activity.
* @return Returns List<ApplicationInfo>.
*/
public static List<ApplicationInfo> getInstalledApplicationList(Activity activity, boolean printToConsole) {
final PackageManager pm = activity.getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
if (!printToConsole) return packages;
int pAccessFineLocation =
ContextCompat.checkSelfPermission(
context, Manifest.permission.ACCESS_FINE_LOCATION);
int pAccessCoarseLocation =
ContextCompat.checkSelfPermission(
context, Manifest.permission.ACCESS_COARSE_LOCATION);
if (pAccessFineLocation == PackageManager.PERMISSION_GRANTED
&& pAccessCoarseLocation == PackageManager.PERMISSION_GRANTED) {
//Yay! We have permission!