Index: trunk/autoquest-androidmonitor/src/main/java/de/ugoe/cs/autoquest/androidmonitor/AndroidMonitor.java
===================================================================
--- trunk/autoquest-androidmonitor/src/main/java/de/ugoe/cs/autoquest/androidmonitor/AndroidMonitor.java	(revision 1833)
+++ trunk/autoquest-androidmonitor/src/main/java/de/ugoe/cs/autoquest/androidmonitor/AndroidMonitor.java	(revision 1842)
@@ -19,8 +19,4 @@
 import de.ugoe.cs.autoquest.androidmonitor.AndroidMonitorCompositeOnClickListener;
 import android.app.Activity;
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
 import android.os.Build;
 import android.text.Editable;
@@ -48,5 +44,5 @@
      * </p>
      */
-    String activityName;
+    private String activityName;
 
     /**
@@ -55,5 +51,5 @@
      * </p>
      */
-    private AndroidMonitorLogFile logFile;
+    private static AndroidMonitorLogFile logFile = null;
 
     /**
@@ -66,4 +62,5 @@
         return monitor;
     }
+   
 
     /**
@@ -73,15 +70,15 @@
      */
     public void startMonitor(Activity activity) {
-        activityName = activity.getClass().getSimpleName();
-
-        logFile = new AndroidMonitorLogFile(getAppLable(activity), activity.getFilesDir());
-
+        //create logFile only once
+        if(AndroidMonitor.logFile == null){
+            AndroidMonitor.logFile = new AndroidMonitorLogFile(activity);
+            Log.i("logfile", "file created");
+        }
+        activityName = activity.getClass().getSimpleName();  
         addLogListenerToView(getRootView(activity));
+        
 
         // TODO
         // listen to changes and update own listener
-        // find out if it is possible to directly call addLogListenerToView
-        // again
-        // activity.onContentChanged();
 
         // write backPresss as event to xml file
@@ -93,12 +90,15 @@
         // http://developer.android.com/training/basics/activity-lifecycle/stopping.html
     }
-
-    /**
-     * get the root view of an activity
+    public void startMonitor(View view){
+        addLogListenerToView(findFirstView(view));
+    }
+    
+    /**
+     * Get the root view of an activity.
      * 
      * @param activity
      * @return
      */
-    public View getRootView(Activity activity) {
+    private View getRootView(Activity activity) {
         // get root view of the activity as start point
         View view = activity.getWindow().getDecorView().getRootView();
@@ -111,5 +111,5 @@
 
     /**
-     * returns first view element of the tree
+     * Returns first view element of the tree.
      * 
      * @param view
@@ -127,10 +127,10 @@
     /**
      * Replace the listener of each view with a composite listener which collects several listeners
-     * for one view.
+     * for one view. Add a TextWatcher to all TexView views.
      * 
      * @param view
      *            to be monitored
      */
-    public void addLogListenerToView(View view) {
+    private void addLogListenerToView(View view) {
         addLogListenerToView(view, 0);
     }
@@ -147,11 +147,54 @@
     private void addLogListenerToView(View view, int parentHash) {
 
-        if (!logFile.isComponentLogged(view.hashCode())) {
-            logFile.addComponent(view, parentHash, activityName);
+        if (!AndroidMonitorLogFile.isComponentLogged(view.hashCode())) {
+            AndroidMonitor.logFile.addComponent(view, parentHash, activityName);
+
+            // save original listener to add it later on to the groupLisatener
+            View.OnClickListener onClickListener = getOnClickListener(view);
+
+            if (onClickListener != null) {
+                // create new compositeOnClickListener to handle multiple listeners
+                // for one view
+                AndroidMonitorCompositeOnClickListener groupListener =
+                    new AndroidMonitorCompositeOnClickListener();
+                // replace the original onClickListener with the
+                // compositeOnClickListener
+                view.setOnClickListener(groupListener);
+                // add the tracking part as a several listener
+                groupListener.addOnClickListener(new View.OnClickListener() {
+                    public void onClick(View v) {
+
+                        AndroidMonitor.logFile.addEvent(v, "onClick");
+                        // check if something changed in the activity
+                        startMonitor(v);
+                    }
+                });
+
+                groupListener.addOnClickListener(onClickListener);
+            }
+            // if view is a TextView add a addTextChangedListener to this view
+            if (view instanceof TextView) {
+                final int hashOfView = view.hashCode();
+                TextView textView = (TextView) view;
+                textView.addTextChangedListener(new TextWatcher() {
+                    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+                        // do nothing
+                    }
+
+                    public void onTextChanged(CharSequence s, int start, int before, int count) {
+                        // do nothing
+                    }
+
+                    public void afterTextChanged(Editable s) {
+                        AndroidMonitor.logFile.addEvent(hashOfView, "text", s.toString());
+                    }
+
+                });
+            }
         }
 
         // hash code of the actual view element. Problem in using
         // view.getParent().hashCode() is described in
-        // de.ugoe.cs.autoquest.androidmonitor#addComponent()
+        // de.ugoe.cs.autoquest.androidmonitor.AndroidMonitorLogFile#addComponent()
         parentHash = view.hashCode();
         // traverse all views of the activity
@@ -164,44 +207,4 @@
         }
 
-        // save original listener to add it later on to the groupLisatener
-        View.OnClickListener onClickListener = getOnClickListener(view);
-
-        if (onClickListener != null) {
-            // create new compositeOnClickListener to handle multiple listeners
-            // for one view
-            AndroidMonitorCompositeOnClickListener groupListener =
-                new AndroidMonitorCompositeOnClickListener();
-            // replace the original onClickListener with the
-            // compositeOnClickListener
-            view.setOnClickListener(groupListener);
-            // add the tracking part as a several listener
-            groupListener.addOnClickListener(new View.OnClickListener() {
-                public void onClick(View v) {
-
-                    logFile.addEvent(v, "onClick");
-                }
-            });
-
-            groupListener.addOnClickListener(onClickListener);
-        }
-        // if view is a TextView add a addTextChangedListener to this view
-        if (view instanceof TextView) {
-            final int hashOfView = view.hashCode();
-            TextView textView = (TextView) view;
-            textView.addTextChangedListener(new TextWatcher() {
-                public void beforeTextChanged(CharSequence s, int start, int count, int after) {
-                    // do nothing
-                }
-
-                public void onTextChanged(CharSequence s, int start, int before, int count) {
-                    // do nothing
-                }
-
-                public void afterTextChanged(Editable s) {
-                    logFile.addEvent(hashOfView, "text", s.toString());
-                }
-
-            });
-        }
     }
 
@@ -212,5 +215,5 @@
      * @return the listener of the view or null if no listener exists
      */
-    public View.OnClickListener getOnClickListener(View view) {
+    private View.OnClickListener getOnClickListener(View view) {
         // http://stackoverflow.com/questions/11186960/getonclicklistener-in-android-views
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
@@ -280,23 +283,17 @@
     }
 
-    /**
-     * get application name as defined in Package Name
-     * 
-     * @param pContext
-     *            package context; could also be an activity
-     * @return app name
-     */
-    public String getAppLable(Context pContext) {
-        // source (2014-09-04):
-        // http://stackoverflow.com/questions/11229219/android-get-application-name-not-package-name
-        PackageManager lPackageManager = pContext.getPackageManager();
-        ApplicationInfo lApplicationInfo = null;
-        try {
-            lApplicationInfo =
-                lPackageManager.getApplicationInfo(pContext.getApplicationInfo().packageName, 0);
-        }
-        catch (final NameNotFoundException e) {}
-        return (String) (lApplicationInfo != null ? lPackageManager
-            .getApplicationLabel(lApplicationInfo) : "Unknown");
+    
+    
+    /**
+     * 
+     * <p>
+     * Return the AndroidMonitorLogFile that is used in the AndroidMonitor.
+     * </p>
+     *
+     * @return AndroidMonitorLogFile 
+     *          that is used in the AndroidMonitor.
+     */
+    public AndroidMonitorLogFile getLogFile(){
+        return logFile;        
     }
 }
