I have a layout which consists some buttons. If I tap the buttons very fast (like a crazy)
I've got this error: Choreographer: Skipped X frames! The application may be doing too much work on its main thread.
These buttons have no specific background or click/tap listener.
I think the onDraw method of these buttons interrupt the main thread too long.
Can I use a flag or something to prevent this? So I would like to send a message to the Choreographer/Looper to skip all event not just some frame.
If I use a layout with complex hierarchy and I tap buttons with listeners the application freezes. Loading screen/dialog it' not an option for me... Any idea?
this is the layout of my fragment: (it's inside a FrameLayout)
<LinearLayout
android:id="@+id/second_line"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="96dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_weight="1"
android:weightSum="6"
android:padding="0dp"
android:layout_marginLeft="0dip"
android:layout_marginRight="0dip"
android:layout_marginTop="0dip"
android:layout_marginBottom="0dip">
<Button
android:layout_width="161dp"
android:layout_height="96dp"
android:id="@+id/indicator3"
android:padding="0dp"
android:layout_marginLeft="0dip"
android:layout_marginRight="0dip"
android:layout_marginTop="0dip"
android:layout_marginBottom="0dip"
android:scaleType="fitXY"/>
<Button
android:layout_width="161dp"
android:layout_height="96dp"
android:id="@+id/indicator4"
android:padding="0dp"
android:layout_marginLeft="0dip"
android:layout_marginRight="0dip"
android:layout_marginTop="0dip"
android:layout_marginBottom="0dip"
android:scaleType="fitXY" />
<Button
android:layout_width="161dp"
android:layout_height="96dp"
android:id="@+id/indicator5"
android:padding="0dp"
android:layout_marginLeft="0dip"
android:layout_marginRight="0dip"
android:layout_marginTop="0dip"
android:layout_marginBottom="0dip"
android:scaleType="fitXY"/>
<Button
android:layout_width="161dp"
android:layout_height="96dp"
android:id="@+id/indicator6"
android:padding="0dp"
android:layout_marginLeft="0dip"
android:layout_marginRight="0dip"
android:layout_marginTop="0dip"
android:layout_marginBottom="0dip"
android:scaleType="fitXY" />
<Button
android:layout_width="161dp"
android:layout_height="96dp"
android:id="@+id/indicator7"
android:padding="0dp"
android:layout_marginLeft="0dip"
android:layout_marginRight="0dip"
android:layout_marginTop="0dip"
android:layout_marginBottom="0dip"
android:scaleType="fitXY"/>
<Button
android:layout_width="161dp"
android:layout_height="96dp"
android:id="@+id/indicator8"
android:padding="0dp"
android:layout_marginLeft="0dip"
android:layout_marginRight="0dip"
android:layout_marginTop="0dip"
android:layout_marginBottom="0dip"
android:scaleType="fitXY"/>
</LinearLayout>
Finally, I find the solution. It's a kiosk application, so I'm disable the notifocation bar by this post: Prevent status bar for appearing android (modified)
Every click triggered an event to add a view to window. So I check that the view already added to the window or not. It's solved my problem.