Skip to content

Instantly share code, notes, and snippets.

View taywils's full-sized avatar
🏠
Working from home

taywils

🏠
Working from home
View GitHub Profile
@taywils
taywils / HelloGist.c
Last active December 14, 2015 23:19
Trying out GitHub Gist for the first time.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv) {
puts("Hello Gist!");
return EXIT_SUCCESS;
}
@taywils
taywils / AndroidPlacesTutorial_AndroidManifest.xml
Created May 7, 2013 16:27
The AndroidManifest XML file for the Google Places API tutorial on my blog
<?xml version="1.0" encoding="utf-8"?>
<!-- AndroidManifest.xml -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8"/>
@taywils
taywils / AndroidPlacesTutorial_HttpTestActivity_Part_1.java
Last active December 17, 2015 02:18
The first part of the Main Activity file for my Android Places API Tutorial
package com.example;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.app.ProgressDialog;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.os.Bundle;
@taywils
taywils / AndroidPlacesTutorial_strings.xml
Created May 7, 2013 17:30
The /res/values/strings.xml file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MapsListing</string>
<string name="httptestlist_textview">Please Wait...</string>
</resources>
public class HttpTestActivity extends Activity {
private String latitude;
private String longitude;
private String provider;
private final String APIKEY = //PLACE YOUR API_KEY HERE!
private final int radius = 2000;
private String type = "food";
private StringBuilder query = new StringBuilder();
private ArrayList<Place> places = new ArrayList<Place>();
private ListView listView;
@taywils
taywils / AndroidPlacesTutorial_HttpTestActivity_Part_3.java
Created May 23, 2013 06:36
The onCreate() method for the Android Google Places Tutorial
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.httptestlist);
LocationManager locationManager = (LocationManager) getSystemService(
Context.LOCATION_SERVICE);
LocationListener myLocationListener = new MyLocationListener();
@taywils
taywils / AndroidPlacesTutorial_HttpTestActivity_Part_4.java
Created May 23, 2013 06:45
loadXMLFromString and GetCurrentLocation
public static Document loadXMLFromString(String xml) throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource is = new InputSource(new StringReader(xml));
return builder.parse(is);
}
private class GetCurrentLocation extends AsyncTask<Object, String, Boolean> {
@taywils
taywils / AndroidPlacesTutorial_HttpTestActivity_Part_5.java
Created May 23, 2013 06:48
QueryGooglePlaces doInBackground Method
/**
* Based on: http://stackoverflow.com/questions/3505930
*/
private class QueryGooglePlaces extends AsyncTask<String, String, String> {
@Override
protected String doInBackground(String... args) {
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response;
String responseString = null;
@taywils
taywils / AndroidPlacesTutorial_HttpTestActivity_Part_6.java
Last active December 17, 2015 15:39
QueryGooglePlaces onPostExecute method
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
try {
Document xmlResult = loadXMLFromString(result);
NodeList nodeList = xmlResult.getElementsByTagName("result");
for(int i = 0, length = nodeList.getLength(); i < length; i++) {
Node node = nodeList.item(i);
/**
* Represents a single Result of a places API call
* https://developers.google.com/places/documentation/search
* This class was mostly auto-generated by IntelliJ IDEA
*/
private class Place {
public String vicinity;
public float[] geometry; //array(0 => lat, 1 => lng)
public String id;
public String name;