네트워크 상태에 따라 다른보기를로드 중입니다. 네트워크를 사용할 수있을 때 조각을로드하고 네트워크를 사용할 수없는 경우 이미지를로드하고 있습니다.Error : android.view.InflateException : 이진 XML 파일 줄 : 클래스 조각을 inflating하는 중 오류가 발생했습니다.
1 단계 : 인터넷에 연결된 장치와 응용 프로그램 시작 코드는 오류를 재현
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!isConnectedToNetwork()) {
setContentView(R.layout.no_internet_connection);
Toast.makeText(getApplicationContext(), "Not connected to internet. Cannot display the map.", Toast.LENGTH_LONG).show();
}
}
@Override
protected void onResume() {
super.onResume();
if (isConnectedToNetwork()) {
setContentView(R.layout.activity_display_map);
setUpViews();
} else {
stopService(new Intent(getApplicationContext(), VoiceLaunchService.class));
setContentView(R.layout.no_internet_connection);
Toast.makeText(getApplicationContext(), "Not connected to internet. Cannot display the map.", Toast.LENGTH_LONG).show();
}
}
private void setUpViews() {
map = ((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
}
단계 아래에 표시됩니다. 지도가 표시됩니다. 2 단계 : 기기를 인터넷에서 연결 해제합니다 (앱이 백그라운드로 전송 됨). 이제 앱에 '인터넷 연결 없음'페이지가 표시됩니다 (앱이 전면에 표시됩니다). 3 단계 : 이제 다시 인터넷에 연결하십시오. 다음 오류는 아래에 표시됩니다.
java.lang.RuntimeException : 활동을 재개 할 수 없습니다. android.view.InflateException : 바이너리 XML 파일 라인 # 2 : 오류 팽창 클래스 단편
내 레이아웃 파일 내가 잘못 가고 어디 이해 didnt가
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
다음과 같이 확인 할 수 있습니다. 나는이 사이트의 모든 솔루션을 헛되이 훑어 보았다. 어떤 도움 감사 드리겠습니다
확인 인터넷 연결과 활동을 확장하고 HTTP를 작동합니까 : //stackoverflow.com/questions/4238921/detect-whether-there-is-an-internet-connection-available-on-android –
** ent를 게시하십시오. ire ** 스택 추적. – CommonsWare
Fragment XML 레이아웃에 문제가 있습니다. plz 귀하의 Fragment xml Layout 또는 Fragment Class 게시하기 –