Skip to content

Instantly share code, notes, and snippets.

@Antarix
Antarix / CreateDirectories.java
Last active Nov 24, 2016
Create Directories on Android SdCard. Simply pass the url as a parameter e.g "/myfolder/newFolder"
View CreateDirectories.java
public void createDirectories(String url) {
Log.d("DIRECTORY CHECK", "Checking directory " + url + " exist or not");
File SDCardRoot = new File(Environment.getExternalStorageDirectory()
.toString() + url);
if (!SDCardRoot.exists()) {
Log.d("DIRECTORY CHECK",
"Directory doesnt exist creating directory "
+ Environment.getExternalStorageDirectory()
.toString());
boolean outcome = SDCardRoot.mkdirs();
@Antarix
Antarix / UrlImageParser.java
Created Nov 29, 2012
UrlImage Parser for android TextView to load Html Image tag
View UrlImageParser.java
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import android.content.Context;
import android.graphics.Canvas;
@Antarix
Antarix / layout_border_bottom
Created Feb 3, 2013
Setting specific border i.e top,bottom,left,right or all for Android layout
View layout_border_bottom
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape
android:shape="rectangle">
<!-- Set the border color of your layout here -->
<stroke android:width="1dp" android:color="#3AFB03" />
<solid android:color="#3AFB03" />
</shape>
@Antarix
Antarix / PreapareListFromXML.java
Last active Dec 12, 2015
fetches data from local Android xml folder having xml file and returns in Arraylist
View PreapareListFromXML.java
public ArrayList<string> prepareListFromXml() {
ArrayList<string> todoItems = new ArrayList<string>();
XmlResourceParser todolistXml = getResources().getXml(R.xml.todolist);
int eventType = -1;
@Antarix
Antarix / XMLParser.java
Created Feb 6, 2013
Load XML data from Url
View XMLParser.java
package com.topchart;
import java.io.IOException;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
@Antarix
Antarix / round_background.xml
Created Feb 7, 2013
Round background image drawable for android
View round_background.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
<stroke android:width="1dp" android:color="#FFFFFF" />
<gradient
android:startColor="#679031"
android:centerColor="#679031"
@Antarix
Antarix / JSONParser.java
Last active Feb 6, 2020
Load Json from Url
View JSONParser.java
import android.content.ContentValues;
import android.content.Context;
import android.util.Log;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
View CarouselView.java
package com.thuytrinh.cardselectordemo;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.app.Activity;
@Antarix
Antarix / SDImageLoader.java
Last active Nov 24, 2016
This Class help you to load Image from SDcard to your listview Asynchronously
View SDImageLoader.java
import java.lang.ref.WeakReference;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.widget.ImageView;
/*
@Antarix
Antarix / SendSMS.java
Created Aug 23, 2013
Send SMS in android with delivery report
View SendSMS.java
//---sends an SMS message to another device---
private void sendSMS(String phoneNumber, String message)
{
String SENT = "SMS_SENT";
String DELIVERED = "SMS_DELIVERED";
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0,
new Intent(SENT), 0);