package fr.neamar.kiss.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.util.Log;

import fr.neamar.kiss.KissApplication;

/**
 * This class gets called when an application is created or removed on the
 * system
 * <p/>
 * We then recreate our data set.
 *
 * @author dorvaryn
 */
public class NewAppInstalledHandler extends BroadcastReceiver {

    @Override
    public void onReceive(Context ctx, Intent intent) {

        if ("android.intent.action.PACKAGE_ADDED".equals(intent.getAction())) {
            //add new package to history
            String packageName = intent.getData().getSchemeSpecificPart();
            String className = ctx.getPackageManager().getLaunchIntentForPackage(packageName).getComponent().getClassName();
            KissApplication.getDataHandler(ctx).addToHistory(ctx, "app://" + packageName+"/"+className);
        }

        KissApplication.resetDataHandler(ctx);
    }

}

@@ -136,114 +136,8 @@
 ent;
-%0Aimport android.content.pm.PackageInfo;%0Aimport android.content.pm.PackageManager;%0Aimport android.util.Log;
 %0A%0Aim
@@ -562,17 +562,18 @@
       //
-a
+ A
 dd new p
@@ -786,24 +786,65 @@
 lassName();%0A
+            if (className != null) %7B%0A    
             
@@ -923,13 +923,17 @@
 Name
-+%22/%22+
+ + %22/%22 + 
 clas
@@ -940,16 +940,30 @@
 sName);%0A
+            %7D%0A
         

Handle null case