This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void printStackTraceWithTag(Exception e, String tag) | |
{ | |
StringWriter stringWriter = new StringWriter(); | |
PrintWriter printWriter = new PrintWriter(stringWriter); | |
e.printStackTrace(printWriter); | |
Log.e(tag,stringWriter.toString()); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExampleAsyncTask extends AsyncTask<Void, Void, ResultObject> | |
{ | |
private final String _inputParameter; | |
// Constuctor | |
public LogInTask(String _inputParameter) | |
{ | |
_inputParameter = inputParameter; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExampleAdapter extends ArrayAdapter<String> { | |
private LayoutInflater _inflater; | |
// | |
// Initialize the adaptor with an Array List of items to display. | |
// | |
public ExampleAdapter(Context context, ArrayList<String> strings) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String parseInputStream(InputStream inputStream) throws Exception | |
{ | |
XmlPullParser parser = Xml.newPullParser(); | |
parser.setInput(inputStream, null); | |
int eventType = parser.getEventType(); | |
while (eventType != XmlPullParser.END_DOCUMENT) { | |
switch (eventType){ | |
case XmlPullParser.START_DOCUMENT: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// .jar from: | |
// http://code.google.com/p/google-gson/ | |
import java.util.List; | |
import com.google.gson.Gson; | |
public class Test { | |
public static void main(String... args) throws Exception { | |
String json = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package uk.co.digitaljigsaw.utils; | |
import java.util.Calendar; | |
import java.util.Date; | |
import android.R.string; | |
import android.content.Context; | |
import android.content.SharedPreferences; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Uri uri = Uri.parse("tel:4444"); | |
Intent callIntent = new Intent(Intent.ACTION_DIAL, uri); | |
startActivity(callIntent); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public GeoLocationResult getDataObject(InputStream inputStream) throws Exception { | |
// Convert to string | |
String responseString = IOUtils.toString(inputStream, "UTF-8"); | |
// One line parsing FTW! | |
GeoLocationResult geoLocationResult = new Gson().fromJson(responseString, GeoLocationResult.class); | |
// Example to get the location latitude |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)processLoginWithData:(NSData*)data { | |
// | |
// Pull the data in from disk | |
// | |
NSString* responsePath = [[NSBundle mainBundle] pathForResource:@"response" ofType:@"xml"]; | |
NSString* hackedString = [NSString stringWithContentsOfFile:responsePath | |
encoding:NSUTF8StringEncoding | |
error:nil]; | |
data = [hackedString dataUsingEncoding:NSUTF8StringEncoding]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (NSString*) pathForSaving | |
{ | |
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString* documentsDirectory = [paths objectAtIndex:0]; | |
return [documentsDirectory stringByAppendingPathComponent:@"fileName.plist"]; | |
} | |
+ (void) loadFromDisk { | |
NSString* path = [MyClass pathForSaving]; |
OlderNewer