из SplashScreenActivity, я вызываю другую активность.
SplashScreenActivity.java
if (CheckInternet.isInternetConnection(SplashScreenActivity.this)) {
if (CheckInternet.isInternetConnection(SplashScreenActivity.this)) {
Log.e(TAG, "device is online");
//service for device validation from Api
// checkMobile();
Intent i = new Intent(SplashScreenActivity.this, HorizontalNtbActivity.class);
startActivity(i);
} else {
Log.e(TAG, "device is ofline");
}
}
HorizontalNtbActivity.java
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_horizontal_ntb);//error found in this line
checkPermissionNew();
initUI();
}
Logcat приведен ниже:
getService(), serviceName = multiwindow_service_v1 05-21 17:00:48.484 23034-23034/com.policynavtabbar D/FeatureProxyBase: FeatureProxyBase class constructor getService(), serviceName = multiwindow_service_v1 05-21 17:00:48.505 23034-23034/com.policynavtabbar D/AccessibilityManager: setStateLocked: wasEnabled = false, mIsEnabled = false, wasTouchExplorationEnabled = false, mIsTouchExplorationEnabled = false, wasHighTextContrastEnabled = false, mIsHighTextContrastEnabled = false
java.lang.Throwable: setStateLocked at android.view.accessibility.AccessibilityManager.setStateLocked (AccessibilityManager.java:553) в android.view.accessibility.AccessibilityManager.tryConnectToSeribilityMancked (: 636) в android.view.accessibility.AccessibilityManager. (AccessibilityManager.java:226) в android.view.accessibility.AccessibilityManager.getInstance (AccessibilityManager.java:206) в android.view.View.setFlags (View.java:9843)) на android.view.ViewGroup.initViewGroup (ViewGroup.java:536) на android.view.ViewGroup. (ViewGroup.java:525) на android.view.ViewGroup. (ViewGroup.java:520) на android.view.ViewGroup. (ViewGroup.java:516) на android.view.ViewGroup. (ViewGroup.java:512) на android.widget.FrameLayout. (FrameLayout.java:119) на com.android.internal.policy.impl.PhoneWindow $ DecorView. (PhoneWindow.java:2326) в com.android.internal.policy.impl.PhoneWindow.generateDecor (PhoneWindow.java:3463) в com.android.internal.policy.impl.PhoneWindow.installDecor (PhoneWindow.java:3849) на com.android.internal.policy.impl.PhoneWindow.setContentView (PhoneWindow.java:411) на android.app.Activity.setContentView (Activity.java:2186) на com.policynavtabbarbar.Hor HorizontalNtbActivity.onCreate (HorizontalNtbActivity.java:61) в android.app.Activity.performCreate (Activity.java:6111) в android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1112) в android.app.ActivityThread.performLunchActivityThread.java:2481) в android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2614) в android.app.ActivityThread.access $ 800 (ActivityThread.java:178) в android.app.ActivityThread $ H.handleMessage (ActivityThread.Java: 1470) на android.os.Handler.dispatchMessage (Handler.java:111) на android.os.Looper.loop (Looper.java:194) наdroid.app.ActivityThread.main (ActivityThread.java:5643) в java.lang.reflect.Method.invoke (собственный метод) в java.lang.reflect.Method.invoke (Method.java:372) в com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:960) на com.android.internal.os.ZygoteInit.main (ZygoteInit.java:755)
ясделать это для проверки подключения к интернету: -
public static boolean isInternetConnection(Context mcontext) {
ConnectivityManager conMgr = (ConnectivityManager) mcontext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = null;
if (conMgr != null) {
netInfo = conMgr.getActiveNetworkInfo();
}
if (netInfo == null) {
new AlertDialog.Builder(mcontext)
.setIcon(R.drawable.ic_sad)
.setTitle("No Internet Connection")
.setMessage("Please Enable Internet Connection Than Try Again.")
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
})
.setCancelable(false)
.show();
} else {
return true;
}
return false;
}