Index: /trunk/TagTracker/.classpath
===================================================================
--- /trunk/TagTracker/.classpath	(revision 3)
+++ /trunk/TagTracker/.classpath	(revision 3)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="gen"/>
+	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+	<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+	<classpathentry kind="lib" path="libs/android-support-v4.jar"/>
+	<classpathentry kind="output" path="bin/classes"/>
+</classpath>
Index: /trunk/TagTracker/.project
===================================================================
--- /trunk/TagTracker/.project	(revision 3)
+++ /trunk/TagTracker/.project	(revision 3)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>TagTracker</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.ApkBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
Index: /trunk/TagTracker/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- /trunk/TagTracker/.settings/org.eclipse.jdt.core.prefs	(revision 3)
+++ /trunk/TagTracker/.settings/org.eclipse.jdt.core.prefs	(revision 3)
@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5
Index: /trunk/TagTracker/AndroidManifest.xml
===================================================================
--- /trunk/TagTracker/AndroidManifest.xml	(revision 3)
+++ /trunk/TagTracker/AndroidManifest.xml	(revision 3)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="nl.deadpixel.tagtracker.beta"
+    android:versionCode="1"
+    android:versionName="1.0" >
+
+    <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="15"/>
+	<uses-permission android:name="android.permission.NFC" />
+	<uses-feature android:name="android.hardware.nfc" android:required="true" />
+	<uses-permission android:name="android.permission.WAKE_LOCK" />
+	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+    <application
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name" 
+        android:theme="@style/MyTheme">
+        <activity
+            android:name=".TagTrackerActivity"
+            android:label="@string/app_name">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+            <intent-filter>
+    			<action android:name="android.nfc.action.TECH_DISCOVERED"/>
+    			<category android:name="android.intent.category.DEFAULT"/>
+			</intent-filter>
+			<intent-filter>
+                <action android:name="android.nfc.action.TAG_DISCOVERED"/>
+                <category android:name="android.intent.category.DEFAULT"/>
+            </intent-filter>
+			<meta-data android:name="android.nfc.action.TECH_DISCOVERED" android:resource="@xml/techlist" />
+        </activity>
+    </application>
+
+</manifest>
Index: /trunk/TagTracker/bin/jarlist.cache
===================================================================
--- /trunk/TagTracker/bin/jarlist.cache	(revision 3)
+++ /trunk/TagTracker/bin/jarlist.cache	(revision 3)
@@ -0,0 +1,3 @@
+# cache for current jar dependecy. DO NOT EDIT.
+# format is <lastModified> <length> <SHA-1> <path>
+# Encoding is UTF-8
Index: /trunk/TagTracker/gen/nl/deadpixel/tagtracker/beta/BuildConfig.java
===================================================================
--- /trunk/TagTracker/gen/nl/deadpixel/tagtracker/beta/BuildConfig.java	(revision 3)
+++ /trunk/TagTracker/gen/nl/deadpixel/tagtracker/beta/BuildConfig.java	(revision 3)
@@ -0,0 +1,6 @@
+/** Automatically generated file. DO NOT MODIFY */
+package nl.deadpixel.tagtracker.beta;
+
+public final class BuildConfig {
+    public final static boolean DEBUG = true;
+}
Index: /trunk/TagTracker/gen/nl/deadpixel/tagtracker/beta/R.java
===================================================================
--- /trunk/TagTracker/gen/nl/deadpixel/tagtracker/beta/R.java	(revision 3)
+++ /trunk/TagTracker/gen/nl/deadpixel/tagtracker/beta/R.java	(revision 3)
@@ -0,0 +1,38 @@
+/* AUTO-GENERATED FILE.  DO NOT MODIFY.
+ *
+ * This class was automatically generated by the
+ * aapt tool from the resource data it found.  It
+ * should not be modified by hand.
+ */
+
+package nl.deadpixel.tagtracker.beta;
+
+public final class R {
+    public static final class attr {
+    }
+    public static final class drawable {
+        public static final int ic_launcher=0x7f020000;
+    }
+    public static final class id {
+        public static final int Screen=0x7f070000;
+        public static final int status=0x7f070003;
+        public static final int text=0x7f070001;
+        public static final int zend=0x7f070002;
+    }
+    public static final class layout {
+        public static final int main=0x7f030000;
+    }
+    public static final class string {
+        public static final int app_name=0x7f050001;
+        public static final int hello=0x7f050000;
+    }
+    public static final class style {
+        /**  Any customizations for your app running on pre-3.0 devices here 
+ Any customizations for your app running on post-3.0 devices here 
+         */
+        public static final int MyTheme=0x7f060000;
+    }
+    public static final class xml {
+        public static final int techlist=0x7f040000;
+    }
+}
Index: /trunk/TagTracker/proguard-project.txt
===================================================================
--- /trunk/TagTracker/proguard-project.txt	(revision 3)
+++ /trunk/TagTracker/proguard-project.txt	(revision 3)
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
Index: /trunk/TagTracker/project.properties
===================================================================
--- /trunk/TagTracker/project.properties	(revision 3)
+++ /trunk/TagTracker/project.properties	(revision 3)
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-15
Index: /trunk/TagTracker/res/layout/main.xml
===================================================================
--- /trunk/TagTracker/res/layout/main.xml	(revision 3)
+++ /trunk/TagTracker/res/layout/main.xml	(revision 3)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="fill_parent"
+    android:id="@+id/Screen" >
+		 <TextView
+            android:id="@+id/text"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_above="@+id/zend"
+            android:layout_alignParentLeft="true"
+            android:layout_alignParentTop="true" />
+		 
+		 <Button
+            android:id="@+id/zend"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_above="@+id/status"
+            android:layout_alignParentLeft="true"
+            android:text="Verzenden" />
+		 
+        <ToggleButton
+            android:id="@+id/status"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_alignParentBottom="true"
+            android:layout_alignParentLeft="true"
+            android:onClick="onToggleClicked"
+            android:text="ToggleButton"
+            android:textOff="Start"
+            android:textOn="Stop" />
+    </RelativeLayout>
Index: /trunk/TagTracker/res/values-v11/themes.xml
===================================================================
--- /trunk/TagTracker/res/values-v11/themes.xml	(revision 3)
+++ /trunk/TagTracker/res/values-v11/themes.xml	(revision 3)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <style name="MyTheme" parent="@android:style/Theme.Holo">
+        <!-- Any customizations for your app running on post-3.0 devices here -->
+    </style>
+</resources>
Index: /trunk/TagTracker/res/values/strings.xml
===================================================================
--- /trunk/TagTracker/res/values/strings.xml	(revision 3)
+++ /trunk/TagTracker/res/values/strings.xml	(revision 3)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="hello">Hello World, TagTrackerActivity!</string>
+    <string name="app_name">TagTracker</string>
+
+</resources>
Index: /trunk/TagTracker/res/values/themes.xml
===================================================================
--- /trunk/TagTracker/res/values/themes.xml	(revision 3)
+++ /trunk/TagTracker/res/values/themes.xml	(revision 3)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <style name="MyTheme" parent="@android:style/Theme">
+        <!-- Any customizations for your app running on pre-3.0 devices here -->
+    </style>
+</resources>
Index: /trunk/TagTracker/res/xml/techlist.xml
===================================================================
--- /trunk/TagTracker/res/xml/techlist.xml	(revision 3)
+++ /trunk/TagTracker/res/xml/techlist.xml	(revision 3)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <tech-list>
+        <tech>android.nfc.tech.IsoDep</tech>
+        <tech>android.nfc.tech.NfcA</tech>
+        <tech>android.nfc.tech.NfcB</tech>
+        <tech>android.nfc.tech.NfcF</tech>
+        <tech>android.nfc.tech.NfcV</tech>
+        <tech>android.nfc.tech.Ndef</tech>
+        <tech>android.nfc.tech.NdefFormatable</tech>
+        <tech>android.nfc.tech.MifareClassic</tech>
+        <tech>android.nfc.tech.MifareUltralight</tech>
+    </tech-list>
+</resources>
Index: /trunk/TagTracker/src/nl/deadpixel/tagtracker/beta/FileHandler.java
===================================================================
--- /trunk/TagTracker/src/nl/deadpixel/tagtracker/beta/FileHandler.java	(revision 3)
+++ /trunk/TagTracker/src/nl/deadpixel/tagtracker/beta/FileHandler.java	(revision 3)
@@ -0,0 +1,110 @@
+package nl.deadpixel.tagtracker.beta;
+
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import android.os.Environment;
+import android.util.Log;
+
+public class FileHandler {
+        
+	public boolean init()
+	{
+		boolean mExternalStorageAvailable = false;
+		boolean mExternalStorageWriteable = false;
+		String state = Environment.getExternalStorageState();
+
+		if (Environment.MEDIA_MOUNTED.equals(state)) {
+		    // We can read and write the media
+		    mExternalStorageAvailable = mExternalStorageWriteable = true;
+		} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
+		    // We can only read the media
+		    mExternalStorageAvailable = true;
+		    mExternalStorageWriteable = false;
+		} else {
+		    // Something else is wrong. It may be one of many other states, but all we need
+		    //  to know is we can neither read nor write
+		    mExternalStorageAvailable = mExternalStorageWriteable = false;
+		}		
+		
+		if(mExternalStorageAvailable && mExternalStorageWriteable)
+		{
+			File root = new File(Environment.getExternalStorageDirectory(), "TagTracker");
+			if (!root.exists()) {
+	            root.mkdirs();
+	        }
+			return true;
+		}
+		else
+		{
+			return false;
+		}
+	}
+	public void writeUID(String uid, String time, String note)
+	{
+		try {
+			File root = new File(Environment.getExternalStorageDirectory(), "TagTracker");
+		    File xmlfile = new File(root, "tags.log");
+		    FileWriter writer = new FileWriter(xmlfile,true);
+			String tag = 
+	        		"	<tag uid=\"" + uid + "\">\r\n" +
+	        		"		<time>" + time + "</time>\r\n" +
+	        		"		<note>" + note + "</note>\r\n" +
+	        		"	</tag>\r\n";
+			Log.i("TagTracker", "Writing tag " + uid);
+	        writer.append(tag);
+	        Log.i("TagTracker", "Wrote tag " + uid);
+	        writer.flush();
+	        writer.close();	
+		} catch (IOException e) {
+			Log.e("TagTracker", "" + e.getMessage());
+		}
+        	
+	}
+	
+	public void writeStart(String starttime)
+	{
+		try
+	    {
+			File root = new File(Environment.getExternalStorageDirectory(), "TagTracker");
+		    File xmlfile = new File(root, "tags.log");
+		    FileWriter writer = new FileWriter(xmlfile,false);
+	        String start = 
+	        		"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
+	        		"<tags>\r\n" +
+	        		"	<start time=\""+starttime+"\" />\r\n";
+	        Log.i("TagTracker", "Writing start...");
+	        writer.write(start);
+	        Log.i("TagTracker", "Wrote start...");
+	        writer.flush();
+	        writer.close();
+	    }
+	    catch(IOException e)
+	    {
+	         Log.e("TagTracker", ""+ e.getMessage());
+	    }		
+	}
+	public void writeEnd(String endtime)
+	{
+		try
+	    {
+			File root = new File(Environment.getExternalStorageDirectory(), "TagTracker");
+		    File xmlfile = new File(root, "tags.log");
+		    FileWriter writer = new FileWriter(xmlfile,true);
+	        String end =
+	        		"<end time=\""+endtime+"\" />\r\n" +
+	        		"</tags>";
+	        Log.i("TagTracker", "Writing end...");
+	        writer.append(end);
+	        Log.i("TagTracker", "Wrote end...");
+	        writer.flush();
+	        writer.close();
+	    }
+	    catch(IOException e)
+	    {
+	         Log.e("TagTracker", ""+ e.getMessage());
+	    }		
+	}
+}
Index: /trunk/TagTracker/src/nl/deadpixel/tagtracker/beta/TagTrackerActivity.java
===================================================================
--- /trunk/TagTracker/src/nl/deadpixel/tagtracker/beta/TagTrackerActivity.java	(revision 3)
+++ /trunk/TagTracker/src/nl/deadpixel/tagtracker/beta/TagTrackerActivity.java	(revision 3)
@@ -0,0 +1,185 @@
+package nl.deadpixel.tagtracker.beta;
+
+
+import java.io.IOException;
+import java.text.DateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+
+import android.app.Activity;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.IntentFilter.MalformedMimeTypeException;
+import android.media.AudioManager;
+import android.media.MediaPlayer;
+import android.media.RingtoneManager;
+import android.net.Uri;
+import android.nfc.NfcAdapter;
+import android.nfc.tech.NfcA;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.PowerManager;
+import android.os.PowerManager.WakeLock;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.RelativeLayout;
+import android.widget.TextView;
+import android.widget.ToggleButton;
+
+public class TagTrackerActivity extends Activity {
+	private NfcAdapter mAdapter;
+    private PendingIntent mPendingIntent;
+    private IntentFilter[] mFilters;
+    private String[][] mTechLists;
+    private TextView mText;
+    private int mCount = 0;
+    private FileHandler fh = new FileHandler();
+    private boolean writeAllow = false;
+    private ArrayList<String> cardID = new ArrayList<String>();
+    private RelativeLayout mScreen;
+    
+    @Override
+    public void onCreate(Bundle savedState) {
+        super.onCreate(savedState);
+        final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
+        WakeLock mWakeLock;
+        setContentView(R.layout.main);
+        final Button button = (Button) findViewById(R.id.zend);
+        button.setOnClickListener(new View.OnClickListener() {
+            public void onClick(View v) {
+            
+            }
+        });
+        mScreen = (RelativeLayout) findViewById(R.id.Screen);
+        mText = (TextView) findViewById(R.id.text);
+        mText.setText("Scan a tag");
+        mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE,"");    
+        mWakeLock.acquire();
+        mAdapter = NfcAdapter.getDefaultAdapter(this);
+
+        // Create a generic PendingIntent that will be deliver to this activity. The NFC stack
+        // will fill in the intent with the details of the discovered tag before delivering to
+        // this activity.
+        mPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
+
+        // Setup an intent filter for all MIME based dispatches
+        IntentFilter tech = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED);
+        try {
+            tech.addDataType("*/*");
+        } catch (MalformedMimeTypeException e) {
+            throw new RuntimeException("fail", e);
+        }
+        mFilters = new IntentFilter[] {
+               tech,
+        };
+
+        // Setup a tech list for all NfcF tags
+        mTechLists = new String[][] { new String[] { NfcA.class.getName() } };
+    }
+    
+    public void onToggleClicked(View v) {
+        // Perform action on clicks
+        if (((ToggleButton) v).isChecked()) {
+        	if(fh.init())
+            {
+            	fh.writeStart(DateFormat.getDateTimeInstance().format(new Date()));
+            	writeAllow = true;
+            }
+            else
+            {
+            	finish();
+            }
+        } else {
+            fh.writeEnd(DateFormat.getDateTimeInstance().format(new Date()));
+            writeAllow = false;
+            mText = (TextView) findViewById(R.id.text);
+            mText.setText("Scan a tag");
+            cardID.clear();
+        }
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        if (mAdapter != null) mAdapter.enableForegroundDispatch(this, mPendingIntent, mFilters,
+                mTechLists);
+    }
+
+    @Override
+    public void onNewIntent(Intent intent) {
+    	if(writeAllow)
+    	{
+	    	byte[] bid = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID); 
+		    	try
+		    	{
+		    		String uid = getHexString(bid);
+		    		String time = DateFormat.getDateTimeInstance().format(new Date());
+		    		if(!cardID.contains(uid))
+			    	{
+			    		//Log.i("Foreground dispatch", "Discovered tag with ID: " + uid);
+			            //mText.append("\r\n["+time+"] Discovered tag " + ++mCount + " with ID: " + uid);
+			            fh.writeUID(uid, time, "");
+			            cardID.add(uid);
+			            setBackground(0xFF00FF00, 200);
+			    	}
+			    	else
+			    	{
+			    		setBackground(0xFFFF0000, 1000);
+			    		playSound(this.getApplicationContext());
+			    		//mText.append("\r\n["+time+"] Tag ID " + uid + " is already added.");
+			    	}
+		    	}
+		    	catch (Exception e)
+		    	{
+		    		Log.e("TagTracker", "" + e);
+		    	}
+    	}
+    }
+    public void playSound(Context context) throws IllegalArgumentException, SecurityException, IllegalStateException, IOException {
+		Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
+		MediaPlayer mMediaPlayer = new MediaPlayer();
+		mMediaPlayer.setDataSource(context, soundUri);
+		final AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
+		int originalVolume  = audioManager.getStreamVolume(AudioManager.STREAM_ALARM);
+		int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_ALARM);
+		audioManager.setStreamVolume(AudioManager.STREAM_ALARM, maxVolume, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
+		mMediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);
+		mMediaPlayer.setLooping(false);
+		mMediaPlayer.prepare();
+		mMediaPlayer.start();
+		if(!mMediaPlayer.isPlaying())
+		{
+			audioManager.setStreamVolume(AudioManager.STREAM_ALARM, originalVolume, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
+		}
+    }
+    
+    public static String getHexString(byte[] b) throws Exception {
+    	  String result = "";
+    	  for (int i=0; i < b.length; i++) {
+    	    result +=
+    	          Integer.toString( ( b[i] & 0xff ) + 0x100, 16).substring( 1 );
+    	  }
+    	  return result;
+    	}
+    
+    public void setBackground(int color, int time)
+    {
+    	mScreen.setBackgroundColor(color);
+    	Handler handler = new Handler(); 
+        handler.postDelayed(new Runnable() { 
+             public void run() { 
+            	mScreen.setBackgroundColor(android.R.color.black); 
+             } 
+        }, time); 
+    	
+    	
+    }
+    @Override
+    public void onPause() {
+        super.onPause();
+        if (mAdapter != null) mAdapter.disableForegroundDispatch(this);
+    }
+}
Index: /trunk/TagTracker/src/nl/deadpixel/tagtracker/beta/XMLParser.java
===================================================================
--- /trunk/TagTracker/src/nl/deadpixel/tagtracker/beta/XMLParser.java	(revision 3)
+++ /trunk/TagTracker/src/nl/deadpixel/tagtracker/beta/XMLParser.java	(revision 3)
@@ -0,0 +1,64 @@
+package nl.deadpixel.tagtracker.beta;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import android.os.Environment;
+import android.util.Log;
+
+public class XMLParser {
+
+	@SuppressWarnings({ "unchecked", "rawtypes" })
+	public ArrayList init()
+	{
+		ArrayList cardID = new ArrayList();
+		File root = new File(Environment.getExternalStorageDirectory(), "TagTracker");
+	    File xmlfile = new File(root, "tags.log");
+		DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
+		DocumentBuilder builder = null;
+		try {
+		    builder = builderFactory.newDocumentBuilder();
+		} catch (ParserConfigurationException e) {
+		    e.printStackTrace();  
+		}
+		try {
+		    Document document = builder.parse(new FileInputStream(xmlfile));
+		    Element rootElement = document.getDocumentElement();
+		    NodeList nodes = rootElement.getChildNodes();
+		    
+		    for(int i=0; i<nodes.getLength(); i++){
+		      Node node = nodes.item(i);
+		      //Log.d("TagTracker", "[" + i + "] " + node.getNodeName());
+		      if(node instanceof Element){
+		        //a child element to process
+		        Element child = (Element) node;
+		        Log.d("TagTracker", "" + (child.getNodeName() == "tag"));
+		        if(child.getNodeName().equals("tag"))
+		        {
+		        	 Log.d("TagTracker", "Toasting...");
+		        	 String attribute = child.getAttribute("uid");
+		        	 cardID.add(attribute);
+		        }
+		      }
+		    }
+		} catch (SAXException e) {
+		    e.printStackTrace();
+		} catch (IOException e) {
+		    e.printStackTrace();
+		}
+		return cardID;	
+	}
+	
+}
