package com.github.droidfu;

import java.lang.ref.WeakReference;
import java.util.HashMap;

import android.app.Application;
import android.content.Context;

public class DroidFuApplication extends Application {

    private HashMap<String, WeakReference<Context>> contextObjects = new HashMap<String, WeakReference<Context>>();

    public synchronized Context getActiveContext(String className) {
        WeakReference<Context> ref = contextObjects.get(className);
        if (ref == null) {
            return null;
        }
        return ref.get();
    }

    public synchronized void setActiveContext(String className, Context context) {
        WeakReference<Context> ref = new WeakReference<Context>(context);
        this.contextObjects.put(className, ref);
    }

    public synchronized void resetActiveContext(String className) {
        contextObjects.remove(className);
    }
}

@@ -83,16 +83,39 @@
 HashMap;
+%0Aimport java.util.List;
 %0A%0Aimport
@@ -171,16 +171,152 @@
 Context;
+%0Aimport android.content.Intent;%0Aimport android.content.pm.PackageManager;%0Aimport android.content.pm.ResolveInfo;%0Aimport android.net.Uri;
 %0A%0Apublic
@@ -986,32 +986,32 @@
 ng className) %7B%0A
-
         contextO
@@ -1041,11 +1041,1132 @@
 );%0A    %7D
+%0A%0A    /**%0A     * Checks whether there are applications installed which are able to handle%0A     * the given action/data.%0A     * %0A     * @param action%0A     *        the action to check%0A     * @param the%0A     *        data URI to check%0A     * @return true if there are apps which will respond to this action/data%0A     */%0A    public boolean isIntentAvailable(String action, Uri uri) %7B%0A        final Intent intent = (uri != null) ? new Intent(action, uri) : new Intent(action);%0A        List%3CResolveInfo%3E list = getPackageManager().queryIntentActivities(intent,%0A            PackageManager.MATCH_DEFAULT_ONLY);%0A        return list.size() %3E 0;%0A    %7D%0A%0A    /**%0A     * Checks whether there are applications installed which are able to handle%0A     * the given intent.%0A     * %0A     * @param intent%0A     *        the intent to check%0A     * @return true if there are apps which will respond to this intent%0A     */%0A    public boolean isIntentAvailable(Intent intent) %7B%0A        List%3CResolveInfo%3E list = getPackageManager().queryIntentActivities(intent,%0A            PackageManager.MATCH_DEFAULT_ONLY);%0A        return list.size() %3E 0;%0A    %7D
 %0A%7D%0A

add 'isIntentAvailable()' method