Source:
<code>protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_already_registered); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setCustomView(R.layout.custom_sherlock_bar); getSupportActionBar().setTitle(R.string.empty_app_title); devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); cdmDeviceAdmin = new ComponentName(this, AgentDeviceAdminReceiver.class); context = this; resources = context.getResources(); Bundle extras = getIntent().getExtras(); if (extras != null) { if (extras.containsKey(getResources().getString(R.string.intent_extra_fresh_reg_flag))) { freshRegFlag = extras.getBoolean( getResources().getString(R.string.intent_extra_fresh_reg_flag)); } } String registrationId = Preference.getString(context, resources.getString(R.string.shared_pref_regId)); if (registrationId != null && !registrationId.isEmpty()) { regId = registrationId; } if (freshRegFlag) { Preference.putString(context, resources.getString(R.string.shared_pref_registered), resources.getString(R.string.shared_pref_reg_success)); if (!devicePolicyManager.isAdminActive(cdmDeviceAdmin)) { startDeviceAdminPrompt(cdmDeviceAdmin); } freshRegFlag = false; } txtRegText = (TextView) findViewById(R.id.txtRegText); btnUnregister = (Button) findViewById(R.id.btnUnreg); btnUnregister.setTag(TAG_BTN_UNREGISTER); btnUnregister.setOnClickListener(onClickListenerButtonClicked); if (devicePolicyManager.isAdminActive(cdmDeviceAdmin)) { <START> LocalNotification.startPolling(context); <END> isPollingStarted = true; } }</code><technical_language>Ideally start/stop polling Device Admin Enabled/Disabled states. move start/stop polling AgentDeviceAdminReciever's onEnabled() onDisabled() methods</technical_language>

Target:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_already_registered); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setCustomView(R.layout.custom_sherlock_bar); getSupportActionBar().setTitle(Constants.EMPTY_STRING); devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); cdmDeviceAdmin = new ComponentName(this, AgentDeviceAdminReceiver.class); context = this; resources = context.getResources(); Bundle extras = getIntent().getExtras(); if (extras != null) { if (extras.containsKey(getResources().getString(R.string.intent_extra_fresh_reg_flag))) { freshRegFlag = extras.getBoolean( getResources().getString(R.string.intent_extra_fresh_reg_flag)); } } String registrationId = Preference.getString(context, resources.getString(R.string.shared_pref_regId)); if (registrationId != null && !registrationId.isEmpty()) { regId = registrationId; } if (freshRegFlag) { Preference.putString(context, resources.getString(R.string.shared_pref_registered), resources.getString(R.string.shared_pref_reg_success)); if (!devicePolicyManager.isAdminActive(cdmDeviceAdmin)) { startDeviceAdminPrompt(cdmDeviceAdmin); } freshRegFlag = false; } txtRegText = (TextView) findViewById(R.id.txtRegText); btnUnregister = (Button) findViewById(R.id.btnUnreg); btnUnregister.setTag(TAG_BTN_UNREGISTER); btnUnregister.setOnClickListener(onClickListenerButtonClicked); }