Skip to content

Instantly share code, notes, and snippets.

View devrath's full-sized avatar
💭
I'm grateful when for one drop in glass. Since I knw exactly what to do with it

Devrath devrath

💭
I'm grateful when for one drop in glass. Since I knw exactly what to do with it
View GitHub Profile
@devrath
devrath / CustomMapMarker
Created November 25, 2014 10:04
Make custom MapMarker at center of map
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
@devrath
devrath / GoogleMapAPIGeocodingAddressParam
Created November 26, 2014 01:35
Getting address and the LatLng from GoogleMap API using Geocoding by passing address as parameter
package com.example.reversegeocoding;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Locale;
import org.apache.http.HttpEntity;
@devrath
devrath / ApplicationClassAndroid
Created November 26, 2014 02:01
How to use Application class in android
//*****************************************SET these things in Activity*******************************************************//
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AppController appState = ((AppController)getApplicationContext());
//Set the value in application variable
@devrath
devrath / GoogleMapNavigationBackForth
Created November 26, 2014 10:47
Android Maps ... Code to go back and forth in the tabs so error won't be raised
@Override
public void onDestroyView ()
{
// This is necessary so that there is no error raised when you navigate back and forth from the mapfragment
try{
MapFragment fragment = ((MapFragment) getFragmentManager().findFragmentById(R.id.map));
FragmentTransaction ft = getActivity().getFragmentManager().beginTransaction();
ft.remove(fragment);
ft.commit();
}catch(Exception e){
@devrath
devrath / SimpleDateFormat
Created November 27, 2014 11:51
Convert one date format to another
String startDateString = edtTxtDateId.getText().toString();
String newDateString = null;
DateFormat df = new SimpleDateFormat("yyyy/mm/dd",Locale.ENGLISH);
DateFormat sdf = new SimpleDateFormat("mm/dd/yyyy",Locale.ENGLISH);
Date startDate;
try {
startDate = sdf.parse(startDateString);
newDateString = df.format(startDate);
System.out.println(newDateString);
} catch (ParseException e) {
@devrath
devrath / GetPostRequest
Created December 2, 2014 20:57
GET AND POST REQUEST
public class UrlConnection {
private static final String TAG = "DownloadData";
public static String executeGet(String requestUrl)
throws IOException {
InputStream inputStream = null;
String response="";
HttpURLConnection urlConnection = null;
/* forming th java.net.URL object */
@devrath
devrath / CheckboxAdapter
Created December 16, 2014 14:01
Checkbox adapter
package com.windhyaworks.adapters;
import java.util.List;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
@devrath
devrath / UTC Time Zone
Created December 17, 2014 12:26
Indian UTC time ZONE conversion
String date=jsonobject.getString("needbydate");
DateFormat df = new SimpleDateFormat("MMM/dd/yyyy",Locale.ENGLISH);
df.setTimeZone(TimeZone.getTimeZone("UTC"));
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss",Locale.ENGLISH);
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
Date startDate;
startDate = sdf.parse(date);
needbydate = df.format(startDate).toString()+"";
package com.emil.android.util;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;
/**
* Check device's network connectivity and speed
* @author emil http://stackoverflow.com/users/220710/emil
@devrath
devrath / Locator.java
Last active August 29, 2015 14:19 — forked from emil2k/Locator.java
package com.emil.android.util;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;
/**