I need to pass several webview, to AsyncTask and they need to run in the same woe, but I'm not getting a return, I do not know how. My application has several AnyChart (Graphics) in the same layout and always returns error of Skip frame or says that WebView has to run in the same woe as the main thread.
This is my Async class:
private class LoadChart extends AsyncTask<AnyChartView, Void, Void> {
@Override
protected Void doInBackground(AnyChartView... any) {
/*Your background work here */
any[0] = (AnyChartView) getView().findViewById(R.id.bar_doughnut1);
any[1] = (AnyChartView) getView().findViewById(R.id.bar_doughnut2);
pieChart(any[0]);
pieChart(any[1]);
return null;
}
}
This my layout:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/linlay1"
android:id="@+id/relBarChart"
android:padding="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:text="Publicações"
android:layout_marginStart="10dp"
android:id="@+id/tv_bar_chart"
android:textColor="@color/grey"
android:textStyle="bold"
android:textSize="12sp"
android:layout_marginBottom="10dp"/>
<com.anychart.AnyChartView
android:id="@+id/bar_doughnut1"
android:layout_below="@+id/tv_bar_chart"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
<LinearLayout
android:id="@+id/linlay2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/relBarChart"
android:orientation="horizontal"
android:padding="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="5dp"
android:layout_marginStart="5dp"
android:background="@color/white">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:text="Publicações"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:id="@+id/tv_bar_doughnut2"
android:textColor="@color/grey"
android:textStyle="bold"
android:textSize="12sp"
android:layout_marginBottom="10dp"/>
<com.anychart.AnyChartView
android:id="@+id/bar_doughnut2"
android:layout_below="@+id/tv_bar_doughnut2"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
Even when you have only one AnyChartView in the layout it returns the Skip frame error, however the graphic opens.