Skip to content

Instantly share code, notes, and snippets.

View walteranyika's full-sized avatar

elCoder walteranyika

View GitHub Profile
@walteranyika
walteranyika / fetch.php
Created November 12, 2015 10:40
Sample code for JSON Data. It fetches and encodes data into JSON format
<?php
header("content-type:application/json");
mysql_connect("localhost","root","");
mysql_select_db("database");
$sql="select * from table";
$data=array();
$results=mysql_query($sql);
while($r=mysql_fetch_row($results))
{
$data[] = array("title"=>$r[1],"author"=>$r[2]);
@walteranyika
walteranyika / CustomAdapter.java
Last active November 13, 2015 10:42
Sample Custom Adapter Class for CustomList
import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
@walteranyika
walteranyika / CodeSnippet.java
Last active November 12, 2015 10:57
Android Java Code To Fetch Data From A particular URL using AsyncHttpClient library
AsyncHttpClient client=new AsyncHttpClient();
client.get(URL, new AsyncHttpResponseHandler()
{
@Override
public void onSuccess(int arg0, Header[] arg1, byte[] response) {
String data =new String(response);
}
@Override
@walteranyika
walteranyika / Incoming.java
Created November 16, 2015 09:03
Broadcast receiver code to read incoming sms
public void onReceive(Context context, Intent intent){
final SmsManager sms = SmsManager.getDefault();
final Bundle bundle = intent.getExtras();
try {
if (bundle != null) {
final Object[] pdusObj = (Object[]) bundle.get("pdus");
@walteranyika
walteranyika / Database.java
Last active November 16, 2015 10:34
Sample database code to create SQLite Database in Android
import java.util.ArrayList;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import java.util.UUID;
public class Database extends SQLiteOpenHelper {
@walteranyika
walteranyika / AndroidManifext.xml
Created November 17, 2015 08:24
MANIFEST FILE FOR GOOGLE GCM NOTIFICATION APP
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.walter.push" >
<!-- GCM Permissions - Start here -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
@walteranyika
walteranyika / Updates.java
Created November 17, 2015 10:49
Code To Get Location Updates For An App
try
{
LocationListener listener=new LocationListener() {
@Override
public void onLocationChanged(Location location) {
double lat= location.getLatitude();
double lon = location.getLongitude();
double speed =location.getSpeed();
//do something with this values
}
@walteranyika
walteranyika / Utility.java
Created November 17, 2015 12:39
CODE TO SAVE AND READ FROM TEXT FILES
public static void writeStringAsFile(final String fileContents, String fileName) {
Context context = App.instance.getApplicationContext();
try {
FileWriter out = new FileWriter(new File(context.getFilesDir(), fileName));
out.write(fileContents);
out.close();
} catch (IOException e) {
Logger.logError(TAG, e);
}
}
@walteranyika
walteranyika / Play Store
Last active December 7, 2015 08:08
How to publish to google play store
Go to google play store and login using the following credentials
https://play.google.com/apps/publish/
Username:[email protected]
Password:chemistry@2010
The publishing guide is on the youtube video below
https://www.youtube.com/watch?v=nHaep1HBIwM
You can do your own research on youtube for other videos
@walteranyika
walteranyika / Sms.java
Created December 8, 2015 09:33
Receive SMS Code
final Bundle bundle = intent.getExtras();
try {
if (bundle != null)
{
final Object[] pdusObj = (Object[]) bundle.get("pdus");
for (int i = 0; i < pdusObj.length; i++)
{
SmsMessage currentMessage = SmsMessage.createFromPdu((byte[]) pdusObj[i]);
} // end for loop