Result set changed error on android
<p>I just saw the toddler lock application and was inspired by it. So i just created a sample application to get the same behavior as toddler lock. I was able to get the same behavior on most of the devices but my app fails on motorola Xoom 4.0.3 while the toddler lock works for the same.</p>

<p>Here is my code:</p>

<pre><code>package com.samplelock;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class SampleLockActivity extends Activity {

    private static String TAG = SampleLockActivity.class.getName();
    private OnClickListener onAskForDefaultBtnListener = new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            enableDefaultActivity("SampleLockActivity", SampleeMenu.class);

            resolveDefaultActivity();

            Intent eMenuIntent = new Intent(SampleLockActivity.this, SampleeMenu.class);
            eMenuIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            eMenuIntent.addCategory("android.intent.category.LAUNCHER");
            eMenuIntent.setAction("android.intent.action.MAIN");
            startActivityForResult(eMenuIntent, 10);
        }
    };

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button btnAsk =(Button) findViewById(R.id.button1);
        btnAsk.setOnClickListener(onAskForDefaultBtnListener);
    }

    /*
     * This method enables the activity to be used as default activity
     */
    private void enableDefaultActivity(String callerName, Class paramClass) {
        PackageManager localPackageManager = getPackageManager();
        ComponentName localComponentName = new ComponentName(getApplicationContext(), paramClass);
        localPackageManager.setComponentEnabledSetting(localComponentName, 1, 1);
        Log.i(TAG,callerName + " enableDefaultActivity");
    }

    /*
     * This method disables the activity to be used as default activity
     */
    public void disableDefaultActivity(String callerName, Class paramClass) {
        PackageManager localPackageManager = getPackageManager();
        ComponentName localComponentName = new ComponentName(getApplicationContext(), paramClass);
        localPackageManager.setComponentEnabledSetting(localComponentName, 2, 1);
        Log.i(TAG,callerName + " disableDefaultActivity");
    }

    private void resolveDefaultActivity(){
        Intent localIntent1 = new Intent("android.intent.action.MAIN");
        Intent localIntent2 = localIntent1.addCategory("android.intent.category.HOME");
        ResolveInfo objResolveInfo = getPackageManager().resolveActivity(localIntent1,0);

        if(!objResolveInfo.activityInfo.packageName.equalsIgnoreCase("com.samplelock")){
            Log.i(TAG, objResolveInfo.activityInfo.packageName);
            startActivity(localIntent1);
            android.os.Process.killProcess(android.os.Process.myPid());
        }
    }
}
</code></pre>

<p>I am not able to get the reason for why it is not working.</p>

<pre><code>uid=10022 pid=15297)
04-09 11:27:13.390 I/ActivityManager(  162): Displayed com.samplelock/.SampleLockActivity: +176ms
04-09 11:27:15.410 I/com.samplelock.SampleLockActivity( 4191): SampleLockActivity enableDefaultActivity
04-09 11:27:15.420 I/com.samplelock.SampleLockActivity( 4191): android
04-09 11:27:15.420 I/PackageManager(  162): Result set changed, dropping preferred activity for Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] } type null
04-09 11:27:15.430 I/ActivityManager(  162): START {act=android.intent.action.MAIN cat=[android.intent.category.HOME] cmp=android/com.android.internal.app.ResolverActivity} from pid 4191
</code></pre>
