У меня есть activity
, который показывает webview
вместе с другими views
.Когда я запускаю это действие, webview
загружается просто отлично, но когда я нажимаю кнопку "Назад" и выхожу из activity
, приложение вылетает со следующим журналом.
A/libc: Fatal signal 6 (SIGABRT), code -6 in tid 11620 (RenderThread)
Примечание. Это происходит только на некоторых устройствах, таких как huawei, moto ...
В чем причина этой ошибки?
Как исправить эту ошибку?
XML-код-
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/flashCardScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/flash_card_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff">
<FrameLayout
android:id="@+id/fact_IV"
android:layout_width="match_parent"
android:layout_height="220dp"
android:background="@drawable/curved_flashcard"
android:transitionName="fact_IV_full">
<ImageView
android:id="@+id/flash_card_IV"
android:layout_width="match_parent"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:src="@drawable/dummy_image" />
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="bottom|end"
android:layout_marginLeft="5dp"
android:layout_marginRight="30dp"
android:src="@drawable/bookmark" />
<com.google.android.youtube.player.YouTubePlayerView
android:id="@+id/player"
android:layout_width="match_parent"
android:layout_height="200dp"/>
</FrameLayout>
<TextView
android:id="@+id/category_TV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/fact_IV"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:fontFamily="@font/robotoregular"
android:letterSpacing="0.1"
android:text="Category"
android:textSize="12sp" />
<TextView
android:id="@+id/short_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/category_TV"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:fontFamily="@font/robotoregular"
android:text="Where does it come from?"
android:textColor="#000"
android:textSize="15sp" />
<TextView
android:id="@+id/long_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/short_description"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:fontFamily="@font/robotoregular"
android:lineSpacingExtra="5dp"
android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."
android:textColor="#515151"
android:textSize="14sp" />
<TextView
android:id="@+id/dateTime_TV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/long_description"
android:layout_gravity="bottom"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:fontFamily="@font/robotoregular"
android:text="Name : August 18, 2018 13:00 IST"
android:textSize="10sp" />
<RelativeLayout
android:id="@+id/webViewContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_below="@id/dateTime_TV">
<LinearLayout
android:id="@+id/readMoreFull"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:fontFamily="@font/robotoregular"
android:text="Full Story"
android:textColor="#000" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="10dp"
android:background="@color/logoColor" />
</LinearLayout>
<WebView
android:id="@+id/flash_card_WV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="70dp" />
<ProgressBar
android:id="@+id/webViewLoadingProgress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
Java-код -
htmlWebView.loadUrl(flashCardObject.getLink());
htmlWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String request) {
view.loadUrl(request);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
webViewLoadingProgress.setVisibility(View.GONE);
}
});
htmlWebView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});