/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package my.home.lehome.activity;

import android.app.Activity;
import android.content.Intent;
import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;
import android.view.WindowManager;

import my.home.lehome.R;
import my.home.lehome.helper.NFCHelper;

public class WakeupActivity extends Activity {

    public static final String TAG = WakeupActivity.class.getName();

    public static final String INTENT_VOICE_COMMAND = "my.home.lehome.VOICE_COMMAND";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wakeup);

        Window wind = this.getWindow();
        wind.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
        wind.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
        wind.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
        wind.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    }

    @Override
    protected void onResume() {
        // TODO Auto-generated method stub
        super.onResume();
        Log.d(TAG, "onResume");

        Intent intent = getIntent();
        if (intent.getAction().equals("android.intent.action.VOICE_COMMAND")) {
            Intent voiceIntent = new Intent(INTENT_VOICE_COMMAND);
            startActivity(voiceIntent);
        } else if (intent.getAction().equals(NfcAdapter.ACTION_NDEF_DISCOVERED)) {
            Intent newIntent = NFCHelper.createBroadcastFromNfcIntent(intent);
            sendBroadcast(newIntent);
            finish();
        }
    }

    @Override
    protected void onPause() {
        // TODO Auto-generated method stub
        super.onPause();
        Log.d(TAG, "onPause");
        finish();
    }
}

@@ -860,16 +860,53 @@
 CHelper;
+%0Aimport my.home.common.util.PrefUtil;
 %0A%0Apublic
@@ -2056,24 +2056,126 @@
 COVERED)) %7B%0A
+            if (PrefUtil.getbooleanValue(getApplicationContext(), %22pref_nfc_cmd_enable%22, true)) %7B%0A    
             
@@ -2253,16 +2253,20 @@
         
+    
 sendBroa
@@ -2275,32 +2275,46 @@
 ast(newIntent);%0A
+            %7D%0A
             fini
@@ -2480,16 +2480,16 @@
 ause%22);%0A
-
         
@@ -2493,21 +2493,64 @@
    finish();
+ // TODO - why finish here not in onResume?
 %0A    %7D%0A%7D%0A

Update WakeupActivity.java