问题
I'm developing an android app. I'm using ZXING fragment open source barcode scanning. I have an option to manually input the barcode. So when the user press the manual input button I open a dialog with edit text. Before the dialog appears I pause the camera and scanning. This causes the device to hang, the top bar multiples it self adding it self more and more times until it fills the display. The only way to get out of this situation is to restart the device.
This bug only reproduce in Nexus 5
How can I debug this in DDMS?
I'm clueless :P Any ideas?!
This is how the device looks when this happens and you must restart the device:
Here are my Theme and Styles files as asked by @Apoorv
themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="MybusinessTheme"
parent="@style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">@style/MybusinessActionBar</item>
<item name="android:actionMenuTextColor">@color/white</item>
<item name="android:homeAsUpIndicator">@drawable/ic_home_up</item>
<item name="android:actionOverflowButtonStyle">@style/MybusinessButtonOverFlow</item>
<!-- Remove the shadow of the actionbar -->
<item name="android:windowContentOverlay">@null</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/MybusinessActionBar</item>
<item name="actionMenuTextColor">@color/white</item>
<item name="homeAsUpIndicator">@drawable/ic_home_up</item>
<item name="actionOverflowButtonStyle">@style/MybusinessButtonOverFlow</item>
<!-- For app launching -->
<item name="android:windowBackground">@color/wrntr_purple</item>
</style>
<!-- ActionBar styles -->
<style name="MybusinessActionBar"
parent="@style/Widget.AppCompat.Light.ActionBar">
<item name="android:background">@color/wrntr_purple</item>
<item name="android:titleTextStyle">@style/WarrenteerActionBarTitleText</item>
<!-- Support library compatibility -->
<item name="background">@color/wrntr_purple</item>
<item name="titleTextStyle">@style/WarrenteerActionBarTitleText</item>
</style>
<!-- Over flow button style -->
<style name="MybusinessButtonOverFlow"
parent="@style/Widget.AppCompat.Light.ActionButton.Overflow">
<item name="android:src">@drawable/ic_action_overflow</item>
</style>
<!-- ActionBar title text -->
<style name="WarrenteerActionBarTitleText"
parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/white</item>
</style>
<style name="MybusinessTheme.Wallpaper"
parent="MybusinessTheme">
</style>
</resources>
styles.xml
<resources>
<style name="ActivityBase">
<item name="android:background">@color/white</item>
</style>
<style name="NextButton">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_alignParentBottom">true</item>
<item name="android:layout_alignParentLeft">true</item>
<item name="android:textSize">@dimen/medium_text</item>
<item name="android:textColor">@drawable/next_button_text_color</item>
<item name="android:gravity">center</item>
<item name="android:layout_marginLeft">20dp</item>
<item name="android:layout_marginBottom">20dp</item>
<item name="android:padding">5dp</item>
<item name="android:background">@drawable/next_button_selector</item>
</style>
<style name="PreviousButton" parent="NextButton">
<item name="android:layout_alignParentLeft">false</item>
<item name="android:layout_alignParentRight">true</item>
<item name="android:layout_marginRight">20dp</item>
</style>
<style name="DescriptionText">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_below">@id/welcomeText</item>
<item name="android:textSize">@dimen/medium_text</item>
<item name="android:textColor">@color/mybiz_dark_gray</item>
</style>
<style name="NormalButton">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:padding">10dp</item>
<item name="android:layout_margin">10dp</item>
<item name="android:textColor">@color/white</item>
<item name="android:background">@drawable/button_selector</item>
<item name="android:gravity">center</item>
</style>
<style name="NormalBoldButton">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:padding">10dp</item>
<item name="android:layout_margin">10dp</item>
<item name="android:textColor">@color/white</item>
<item name="android:background">@drawable/button_selector</item>
<item name="android:textStyle">bold</item>
<item name="android:gravity">center</item>
</style>
<style name="LightButton">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:padding">10dp</item>
<item name="android:layout_margin">10dp</item>
<item name="android:textColor">@color/mybiz_dark_gray</item>
<item name="android:background">@drawable/light_button_selector</item>
<item name="android:gravity">center</item>
</style>
<style name="TitleText">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">@color/mybiz_dark_gray</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">@dimen/xx_large_text</item>
</style>
<style name="WizardProgressNumber">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">@color/white</item>
<item name="android:paddingBottom">4dp</item>
<item name="android:paddingTop">7dp</item>
<item name="android:paddingRight">9dp</item>
<item name="android:paddingLeft">9dp</item>
<item name="android:layout_gravity">center</item>
<item name="android:gravity">center</item>
<item name="android:layout_marginLeft">6dp</item>
<item name="android:background">@drawable/white_circle</item>
</style>
<style name="WizardProgressViewDefault">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:padding">5dp</item>
<item name="android:layout_marginRight">15dp</item>
<item name="android:layout_marginTop">@dimen/add_other_device_space</item>
<item name="android:layout_marginBottom">@dimen/add_other_device_space</item>
</style>
<style name="NavigationDrawer">
<item name="android:layout_width">240dp</item>
<item name="android:layout_height">match_parent</item>
<item name="android:layout_gravity">start</item>
<item name="android:choiceMode">singleChoice</item>
<item name="android:divider">@color/mybiz_light_gray</item>
<item name="android:dividerHeight">1dp</item>
<item name="android:background">@android:color/white</item>
</style>
<style name="HomeMenuItem">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">@color/gray_turquoise_selector</item>
<item name="android:textSize">@dimen/medium_text</item>
<item name="android:layout_gravity">center</item>
<item name="android:gravity">center_vertical</item>
<item name="android:layout_margin">10dp</item>
<item name="android:paddingTop">3dp</item>
<item name="android:drawablePadding">10dp</item>
</style>
<style name="ProductListItem">
<item name="android:layout_alignParentRight">true</item>
<item name="android:layout_marginRight">15dp</item>
</style>
<style name="ObjectSeekBar">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">10dp</item>
<item name="android:layout_marginTop">12dp</item>
<item name="android:layout_marginLeft">5dp</item>
<item name="android:layout_marginRight">5dp</item>
<item name="android:padding">0dp</item>
<item name="android:thumb">@null</item>
<item name="android:progressDrawable">@drawable/days_left_progress</item>
</style>
<style name="ObjectBoldSmallText">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">@dimen/small_text</item>
<item name="android:textColor">@color/mybiz_dark_gray</item>
<item name="android:layout_marginRight">15dp</item>
<item name="android:layout_gravity">right</item>
<item name="android:textStyle">bold</item>
</style>
<style name="ObjectSmallText">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">@dimen/small_text</item>
<item name="android:textColor">@color/mybiz_dark_gray</item>
<item name="android:layout_marginRight">15dp</item>
<item name="android:layout_gravity">right</item>
</style>
<style name="ObjectMediumText" parent="ProductListItem">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">@dimen/medium_text</item>
<item name="android:textColor">@color/mybiz_purple</item>
<item name="android:layout_gravity">right</item>
</style>
<style name="ObjectMediumLargeText" parent="ProductListItem">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">@dimen/medium_large_text</item>
<item name="android:textColor">@color/mybiz_purple</item>
<item name="android:layout_gravity">right</item>
</style>
<style name="ObjectLargeText" parent="ProductListItem">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">@dimen/large_text</item>
<item name="android:textColor">@color/mybiz_purple</item>
<item name="android:layout_gravity">right</item>
</style>
<style name="HorizontalLineGray">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1dp</item>
<item name="android:layout_marginTop">5dp</item>
<item name="android:background">@color/mybiz_gray</item>
</style>
<style name="HorizontalLineLightGray">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">0.5dp</item>
<item name="android:layout_marginTop">5dp</item>
<item name="android:background">@color/mybiz_light_gray</item>
</style>
<style name="buttonWhiteBorder">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_gravity">right</item>
<item name="android:textColor">@drawable/button_text_color_selector_white</item>
<item name="android:paddingTop">10dp</item>
<item name="android:paddingBottom">10dp</item>
<item name="android:paddingLeft">20dp</item>
<item name="android:paddingRight">20dp</item>
<item name="android:layout_marginRight">15dp</item>
<item name="android:background">@drawable/button_selector_white_transparent</item>
</style>
<style name="ManualInputButton" parent="buttonWhiteBorder">
<item name="android:layout_marginTop">@dimen/add_other_device_space</item>
<item name="android:layout_alignParentLeft">true</item>
<item name="android:layout_marginLeft">15dp</item>
</style>
<style name="ButtonTurquoiseBorder">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">@drawable/button_text_color_selector_turquoise</item>
<item name="android:background">@drawable/button_selector_turquoise_transparent</item>
</style>
<style name="EditBoldTextLabel" parent="ObjectBoldSmallText">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:gravity">right</item>
<item name="android:layout_marginRight">20dp</item>
<item name="android:layout_marginTop">25dp</item>
</style>
<style name="EditTextLabel" parent="ObjectSmallText">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:gravity">right</item>
<item name="android:layout_marginRight">20dp</item>
<item name="android:layout_marginTop">25dp</item>
</style>
<style name="EditTextManualInputLabel" parent="EditBoldTextLabel">
<item name="android:textColor">@color/white</item>
</style>
<style name="EditTextNormal">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginRight">20dp</item>
<item name="android:layout_marginLeft">20dp</item>
<item name="android:imeOptions">actionNext</item>
<item name="android:singleLine">true</item>
</style>
<style name="EditTextManualInput" parent="EditTextNormal">
<item name="android:textColorHint">@color/mybiz_light_gray</item>
<item name="android:textColor">@color/white</item>
<item name="android:background">@drawable/edit_text_white_selector</item>
</style>
<style name="LargeTextTitle" parent="ObjectLargeText">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">@color/mybiz_dark_gray</item>
<item name="android:layout_marginTop">25dp</item>
</style>
<style name="MediumTextTitle" parent="ObjectMediumText">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">@color/mybiz_dark_gray</item>
<item name="android:layout_marginTop">25dp</item>
</style>
</resources>
回答1:
OK we had the same problem - Nexus 5 only, but with ZBar lib instead of ZXing.
The issue was resolved by switching from a SurfaceView to a TextureView - however this resulted in slower frame rates.
Through testing we found that our issue was caused by leaving the screen, bringing up the keyboard and going back - our solution was setting android:windowSoftInputMode to AdjustPan in the manifest.
Hope this helps!
来源:https://stackoverflow.com/questions/25422568/ddms-debugging-android-app-im-developing-causes-device-only-nexus-5-to-han