An electronic device , comprising: a housing ; a display exposed through a portion of the housing ; a wireless communication circuit disposed in the housing ; a processor disposed in the housing and operatively connected with the display and the wireless communication circuit; and a memory operatively connected with the processor , wherein the memory stores instructions executable by the processor , wherein the instructions are executable by the processor to cause the electronic device to: at a first time point, change the electronic device from a lock state to a unlock state in response to a user's input, at a second time point after the first time point, change the electronic device from the unlock state to the lock state, after the second time point, detect an approach of a stylus pen , within a predetermined distance from a surface of the display in the lock state, at a third time point after the second time point, receive a wireless signal generated by the stylus pen based on the approach of the stylus pen , through the wireless communication circuit, and characterised in that the instructions are further executable by the processor to change the electronic device from the lock state to the unlock state if the third time point is within a first predetermined time from the first time point. a housing ; a display exposed through a portion of the housing ; a wireless communication circuit disposed in the housing ; a processor disposed in the housing and operatively connected with the display and the wireless communication circuit; and a memory operatively connected with the processor , wherein the memory stores instructions executable by the processor , wherein the instructions are executable by the processor to cause the electronic device to: at a first time point, change the electronic device from a lock state to a unlock state in response to a user's input, at a second time point after the first time point, change the electronic device from the unlock state to the lock state, after the second time point, detect an approach of a stylus pen , within a predetermined distance from a surface of the display in the lock state, at a third time point after the second time point, receive a wireless signal generated by the stylus pen based on the approach of the stylus pen , through the wireless communication circuit, and characterised in that the instructions are further executable by the processor to change the electronic device from the lock state to the unlock state if the third time point is within a first predetermined time from the first time point. at a first time point, change the electronic device from a lock state to a unlock state in response to a user's input, at a second time point after the first time point, change the electronic device from the unlock state to the lock state, after the second time point, detect an approach of a stylus pen , within a predetermined distance from a surface of the display in the lock state, at a third time point after the second time point, receive a wireless signal generated by the stylus pen based on the approach of the stylus pen , through the wireless communication circuit, and characterised in that the instructions are further executable by the processor to change the electronic device from the lock state to the unlock state if the third time point is within a first predetermined time from the first time point. <EOS>