0

from SplashScreenActivity i'm calling another Activity.

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 is given below:

 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) at android.view.accessibility.AccessibilityManager.tryConnectToServiceLocked(AccessibilityManager.java:636) at android.view.accessibility.AccessibilityManager.(AccessibilityManager.java:226) at android.view.accessibility.AccessibilityManager.getInstance(AccessibilityManager.java:206) at android.view.View.setFlags(View.java:9843) at android.view.ViewGroup.initViewGroup(ViewGroup.java:536) at android.view.ViewGroup.(ViewGroup.java:525) at android.view.ViewGroup.(ViewGroup.java:520) at android.view.ViewGroup.(ViewGroup.java:516) at android.view.ViewGroup.(ViewGroup.java:512) at android.widget.FrameLayout.(FrameLayout.java:119) at com.android.internal.policy.impl.PhoneWindow$DecorView.(PhoneWindow.java:2326) at com.android.internal.policy.impl.PhoneWindow.generateDecor(PhoneWindow.java:3463) at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3849) at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:411) at android.app.Activity.setContentView(Activity.java:2186) at com.policynavtabbar.HorizontalNtbActivity.onCreate(HorizontalNtbActivity.java:61) at android.app.Activity.performCreate(Activity.java:6111) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2481) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2614) at android.app.ActivityThread.access$800(ActivityThread.java:178) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1470) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5643) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)


i'm doing like this for check internet connection:-

 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;
}
Imen Gharsalli
  • 367
  • 2
  • 13
  • show your isInternetConnection() method. – Danger May 21 '18 at 12:28
  • 2
    Possible duplicate of [How to solve the error like java.lang.Throwable: setStateLocked?](https://stackoverflow.com/questions/38865085/how-to-solve-the-error-like-java-lang-throwable-setstatelocked) – Michael May 21 '18 at 12:36
  • Please try with this: Intent i = new Intent(this, HorizontalNtbActivity.class); – Amit May 21 '18 at 15:54
  • Also use this keyword before methods inside onCreate. I think, its happen for below two methods....You can debug it with comment out those 2 methods. – Amit May 21 '18 at 16:00
  • @Amit when i try this Intent i = new Intent(this, HorizontalNtbActivity.class); that case error found this can't resolve. – Android Developer May 23 '18 at 06:16
  • did you check with commented out checkPermissionNew and initUI methods? I guess this happens for those two methods.. – Amit May 23 '18 at 06:25
  • actually setStateLocked error not getting all-time, it happens randomly then how can I check issue is solved or not? – Android Developer May 23 '18 at 07:06

0 Answers0