Android connection Bluetooth scanning gun, program crash of Onconfigurationchanged

Source: Internet
Author: User

One of the reasons the program crashes when the Android phone connects to the scanner via Bluetooth is that the keyboard pops up or is hidden, triggering the program to go through the ondestory->oncreate life cycle, which may cause some of the page's initialization data to be erased.

Workaround: Typically specify activity in Androidmanifest.xml to add the following code

1 android:configChanges="orientation|keyboard|keyboardHidden"

This code indicates that the Onconfigurationchanged method of the activity is called when the device rotates, displays the keyboard, hides the keyboard, and if this statement does not declare, the OnCreate method is called when a particular event is triggered.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.