Method involving AlarmManager isn't functioning the way I need it to
<p>I have a method named lock that sets a random lock screen password and locks the screen using DevicePolicyManager whenever a button is pressed.  Right before the phone locks, this lock method also schedules an alarm to go off after a certain amount of time. This alarm calls a method to reset the lock screen password to a stored value.  </p>

<p>The issue I am having is whenever the button to call my lock method is pressed, the phone locks like it should, and it also resets the locks screen password to a random one like it should, so that after the phone locks the user can try to unlock it and the lock screen pops up that only accepts the random password.  However if the user presses back at the lock screen and then tries to unlock the phone again, the lock screen password is set right away to the stored pin value.  This also happens if the user locks the phone again and tries to unlock it.  I want the password to be reset after a certain amount of time has passed, not right away.  </p>

<p>I have already configured a DeviceAdmin receiver in another class also.</p>

<p>Am I missing something from my AlarmManager or doing something wrong in my lock method?
<strong>Please note, I am changing the actual device's lock screen password with this method, I am not making my own lock screen.</strong></p>

<p>The lock method in question called when my button is pressed</p>

<pre><code>final Random rand=new Random();

public void lock(View v) {
int diceRoll;

    setMins();

    //this section schedules an alarm that calls my overridden broadcast receiver in this class
    Intent alarmIntent=new Intent(this, AlarmBroadCastReceiver.class);
    PendingIntent pendIntent=PendingIntent.getBroadcast(this, 1, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    alMgr=(AlarmManager) getSystemService(Context.ALARM_SERVICE);
    alMgr.cancel(pendIntent);
    alMgr.set(AlarmManager.ELAPSED_REALTIME, (time * 60000), pendIntent);

    diceRoll=rand.nextInt(9999)+1;

    if (mgr.isAdminActive(cn))
     {
        mgr.setPasswordQuality(cn, DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
        mgr.setPasswordMinimumLength(cn, 0);
         //this sets the lock screen password to a random one
        mgr.resetPassword(Integer.toString(diceRoll), 0);
         mgr.lockNow();
     }
    else {
        Intent intent =
                new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
        intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, cn);
        intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
                getString(R.string.device_admin_explanation));
        startActivity(intent);
    }
}
</code></pre>

<p>this is my resetPasswordAgain method called from my overridden BroadcastReceiver from this class.  this method resets the lock screen password to the stored value</p>

<pre><code>public void resetPasswordAgain()
{
    mgr.setPasswordQuality(cn,  DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
    mgr.setPasswordMinimumLength(cn, 0);

    mgr.resetPassword(SetPinDialogFragment.pin, 0);
}
</code></pre>

<p>overridden broadcast receiver from this class</p>

<pre><code> BroadcastReceiver broadcastReceiver = new BroadcastReceiver()
{
    @Override
    public void onReceive(Context context, Intent intent) {
        resetPasswordAgain();
    }
};
    @Override
    protected void onDestroy()
    {
        super.onDestroy();
        unregisterReceiver(broadcastReceiver);
    }
</code></pre>

<p>I have a basic broadcast receiver in another class also, but this gets overridden by the one shown above</p>

<pre><code>public class AlarmBroadCastReceiver extends BroadcastReceiver
{
    @Override
    public void onReceive(Context context, Intent intent)
    {
        context.sendBroadcast(new Intent("CALL_METHOD"));
    }
}
</code></pre>

<p>Manifest, just in case you need to look at it</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.fbtc141.test3"&gt;

&lt;uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="14" /&gt;
android:versionCode="1"
android:versionName="1.0"&gt;
&lt;uses-feature
    android:name="android.software.device_admin"
    android:required="true" /&gt;



&lt;application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme"&gt;
    &lt;activity
        android:name=".ToggleAdmin"
        android:label="@string/app_name"&gt;

        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.MAIN" /&gt;

            &lt;category android:name="android.intent.category.DEFAULT" /&gt;
            &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
        &lt;/intent-filter&gt;



    &lt;/activity&gt;

    &lt;receiver
        android:name=".AdminReceiver"
        android:permission="android.permission.BIND_DEVICE_ADMIN"&gt;
        &lt;meta-data
            android:name="android.app.device_admin"
            android:resource="@xml/device_admin" /&gt;

        &lt;intent-filter&gt;
            &lt;action android:name="android.app.action.DEVICE_ADMIN_ENABLED" /&gt;
        &lt;/intent-filter&gt;
    &lt;/receiver&gt;

    &lt;receiver android:name=".AlarmBroadCastReceiver"&gt;&lt;/receiver&gt;

&lt;/application&gt;
</code></pre>

<p></p>