Skip to content

Instantly share code, notes, and snippets.

import android.app.Activity;
import android.app.ProgressDialog;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.provider.MediaStore;
/*
* @author Ashish
* https://github.com/ashmeh6
@ashmeh6
ashmeh6 / CustomMultiPartEntity.java
Last active July 5, 2016 05:40
Can be used as HttpPost data with upload percentage
/**
* Created by Ashish on 09-Jun-16.
*/
/**
* Required Library httpmime-4.1-beta1.jar
*
* Example of use
*
* doInBackground(Params...){
private boolean isValidEmail(String email) {
if (TextUtils.isEmpty(email)) {
return false;
}
if (!(email.indexOf('@') > 0 && email.lastIndexOf('.') > (email.indexOf('@') + 1) && (email.length() - 1) != email.lastIndexOf('.'))) {
return false;
}
return true;
}
import android.app.Service;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.IBinder;
import android.provider.Settings;
@ashmeh6
ashmeh6 / Login.java
Last active January 9, 2017 10:56
Google Signing snippet code
/*
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
build.gradle
compile 'com.google.android.gms:play-services-auth:9.0.+'
Release SHA1 :keytool -list -v -keystore path_file.jks -alias Key_Alias_Here -storepass Key_store_Password_Here -keypass Key_Password_Here
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
/**
* Created by Ashish on 25-Jul-16.
*/
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
// do your stuff here
webView.measure(View.MeasureSpec.makeMeasureSpec(
View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED),
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
webView.layout(0, 0, webView.getMeasuredWidth(),
webView.getMeasuredHeight());
webView.setDrawingCacheEnabled(true);
public class CallLogReadAndroid{
public CallLogReadAndroid(){
Uri allCalls = Uri.parse("content://call_log/calls");
StringBuffer sb = new StringBuffer();
sb.append("Call Details :");
Cursor c = managedQuery(allCalls, null, null, null, CallLog.Calls.DATE + " DESC LIMIT 100");
int date = c.getColumnIndex(CallLog.Calls.DATE);
int number = c.getColumnIndex(CallLog.Calls.NUMBER);
int name = c.getColumnIndex(CallLog.Calls.CACHED_NAME);
// String num= c.getString(c.getColumnIndex(CallLog.Calls.NUMBER));// for number
private class FetchAddressFromLocation extends AsyncTask<Void, Void, String> {
private Context context;
private Double latitude;
private Double longitude;
public FetchAddressFromLocation(Context context, Double latitude, Double longitude) {
this.context = context;
this.latitude = latitude;
this.longitude = longitude;