我正在呼叫另一个活动。
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");
}
}
@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:android.view.accessibility.AcessibilityManager.setStateLocked(AccessibilityManager.java:553)中的setStateLocked,位于android.view.accessibility的android.view.accessibility.AccessibilityManager.tryConnectToServiceLocked(AccessibilityManager.java:636) .AccessibilityManager。(AccessibilityManager.java:226)位于android.view.View.InitView.Group上的android.view.accessibility.AccessibilityManager.getInstance(AccessibilityManager.java:206)android.view.View.setFlags(View.java:9843) (ViewGroup.java:536)在Android.view.View的android.view.ViewGroup。(ViewGroup.java:525)。(ViewGroup.java:520)在android.view.ViewGroup。(ViewGroup.java:516)at android.view.ViewGroup。(ViewGroup.java:512)在android.widget.FrameLayout。(FrameLayout.java:119)com.android.internal.policy.impl.PhoneWindow $ DecorView。(PhoneWindow.java:2326)at at com.android.internal.policy.impl.PhoneWindow.gener ateDecor(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上的android.app.Activity.setContentView(Activity.java:6111)的android.app.Activity.setContentView(Activity.java:2186)上的android.app.Activity.performCreate(Activity.java:6111)。 Instrumentation.callActivityOnCreate(Instrumentation.java:1112)在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2481)的android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2614)android.app.ActivityThread.access $ 800( ActivityThread.java:178)在Android.os.Looper.loop(Looper.java)android.app.Handler.dispatchMessage(Handler.java:111)的android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1470) :194)在android.app.Activit yThread.main(ActivityThread.java:5643)位于com.android.internal.os的java.lang.reflect.Method.invoke(Method.java:372)的java.lang.reflect.Method.invoke(Native Method)中。 ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:960)at 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;
}