请我的应用程序在游戏商店中,并且在某些设备上可以正常工作,但是我收到了有关崩溃的投诉,发现该突出显示的第7行多数民众赞成在尝试导致崩溃的原因是检查是否存在互联网连接显示主要布局,否则,如果关闭互联网,则会打开另一个意图,显示没有可用的互联网。
我的困惑是为什么它对某些人和其他人有用的崩溃 请我在做什么错,我该如何解决。 这是我的MainActivity
boolean isConnected() {
boolean internetAvailability = true;
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED ||
connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED) {
}else {
internetAvailability = false;
}
return internetAvailability;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isConnected())
{
setContentView(R.layout.activity_main);
mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");
db = FirebaseDatabase.getInstance().getReference("DAILY BETS");
//GETTING DATA INTO VIEW FROM FIREBASE
db.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
betdataList.clear();
if(dataSnapshot == null)
{
Toast.makeText(getApplicationContext(),"Nothing to Show",Toast.LENGTH_SHORT).show();
}else {
for (DataSnapshot betDataSnapshot : dataSnapshot.getChildren()) {
Betdata bet = betDataSnapshot.getValue(Betdata.class);
betdataList.add(bet);
}
}
predictionsList = new CustomPredictionAdapter(betdataList,getApplicationContext(),resource);
betList.setAdapter(predictionsList);
betList.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
Toast.makeText(getApplicationContext(),"Notification enabled",Toast.LENGTH_SHORT).show();
if (betdataList.size() >0)
{
progressDialog.dismiss();
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
}
);
drawerLayout = findViewById(R.id.drawer);
navigationView = findViewById(R.id.nav_viewer);
// boolean internetAvailability = true;
progressDialog = new ProgressDialog();
progressDialog.show(getSupportFragmentManager(),"Loading");
drawerToggle = new ActionBarDrawerToggle(this,drawerLayout,R.string.open,R.string.close);
betList = findViewById(R.id.list);
betdataList = new ArrayList<>();
navigationView.setNavigationItemSelectedListener(this);
drawerToggle.syncState();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
drawerLayout.addDrawerListener(drawerToggle);
customDialog = new Dialog(this);
}else {
setContentView(R.layout.no_internet_layout);
pullToRefresh = findViewById(R.id.pulldowntorefresh);
pullToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
Intent restartIntent = getBaseContext().getPackageManager()
.getLaunchIntentForPackage(getBaseContext().getPackageName());
restartIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(restartIntent);
pullToRefresh.setRefreshing(false);
}
});
}
}
这里是我的游戏控制台的崩溃报告
java.lang.RuntimeException:在 android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2572)在 android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2654)位于android.app.ActivityThread.-wrap11 (ActivityThread.java)在android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1488)位于android.os.Handler.dispatchMessage (Handler.java:111)在android.os.Looper.loop(Looper.java:207)在 android.app.ActivityThread.main(ActivityThread.java:5728)位于 java.lang.reflect.Method.invoke(本机方法)位于 com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:789)在com.android.internal.os.ZygoteInit.main (ZygoteInit.java:679)原因:android.view.InflateException:在 android.view.LayoutInflater.inflate(LayoutInflater.java:539)位于 android.view.LayoutInflater.inflate(LayoutInflater.java:423)位于 android.view.LayoutInflater.inflate(LayoutInflater.java:374)在 android.support.v7.app.AppCompatDelegateImplV9.setContentView (AppCompatDelegateImplV9.java:287)在 android.support.v7.app.AppCompatActivity.setContentView (AppCompatActivity.java:139)在 com.kenworld.bettingtipsapp.MainActivity.onCreate (MainActivity.java:79)位于android.app.Activity.performCreate (Activity.java:6360)在 android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1113)在 android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2519)由:android.view.InflateException:
在android.view.LayoutInflater.createView(LayoutInflater.java:645)
在android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:764)在 android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:704)位于android.view.LayoutInflater.rInflate (LayoutInflater.java:835)在 android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 在android.view.LayoutInflater.inflate(LayoutInflater.java:515) 造成原因:java.lang.reflect.InvocationTargetException:在 java.lang.reflect.Constructor.newInstance(本机方法),位于 android.view.LayoutInflater.createView(LayoutInflater.java:619) 造成原因:android.content.res.Resources $ NotFoundException:在 android.content.res.Resources.getValue(Resources.java:1566)在 android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates (AppCompatDrawableManager.java:330)在 android.support.v7.widget.AppCompatDrawableManager.getDrawable (AppCompatDrawableManager.java:195)在 android.support.v7.widget.AppCompatDrawableManager.getDrawable (AppCompatDrawableManager.java:188)在 android.support.v7.content.res.AppCompatResources.getDrawable (AppCompatResources.java:100)在 android.support.v7.view.menu.MenuItemImpl.getIcon (MenuItemImpl.java:491)在 android.support.design.internal.NavigationMenuPresenter $ NavigationMenuAdapter.prepareMenuItems (NavigationMenuPresenter.java:519)在 android.support.design.internal.NavigationMenuPresenter $ NavigationMenuAdapter.update (NavigationMenuPresenter.java:460)在 android.support.design.internal.NavigationMenuPresenter.updateMenuView (NavigationMenuPresenter.java:117)在 android.support.design.widget.NavigationView.inflateMenu (NavigationView.java:250)在 android.support.design.widget.NavigationView。 (NavigationView.java:172)在 android.support.design.widget.NavigationView。 (NavigationView.java:98)