title: java lang nullpointerexception but only on samsung GT-N5110 Note 8
body: <p>I have an issue where I can not get my app to work on the note 8.<br>
  Works perfectly on a Galaxy S4 without any error at all as well as an old HTC mobile.</p>
  
  <p>The error I am getting is as follows</p>
  
  <pre><code>02-21 09:21:28.352: W/dalvikvm(6130): threadid=1: thread exiting with uncaught exception     (group=0x41bab930)
  02-21 09:21:28.357: E/AndroidRuntime(6130): FATAL EXCEPTION: main
  02-21 09:21:28.357: E/AndroidRuntime(6130): java.lang.RuntimeException: Unable to start     activity ComponentInfo{com.taskey.me2team/com.taskey.me2team.StartHere}:     java.lang.NullPointerException
  02-21 09:21:28.357: E/AndroidRuntime(6130):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2245)
  02-21 09:21:28.357: E/AndroidRuntime(6130):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2295)
  02-21 09:21:28.357: E/AndroidRuntime(6130):     at android.app.ActivityThread.access$700(ActivityThread.java:150)
  02-21 09:21:28.357: E/AndroidRuntime(6130):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
  02-21 09:21:28.357: E/AndroidRuntime(6130):     at android.os.Handler.dispatchMessage(Handler.java:99)
  02-21 09:21:28.357: E/AndroidRuntime(6130):     at android.os.Looper.loop(Looper.java:137)
  02-21 09:21:28.357: E/AndroidRuntime(6130):     at android.app.ActivityThread.main(ActivityThread.java:5279)
  02-21 09:21:28.357: E/AndroidRuntime(6130):     at java.lang.reflect.Method.invokeNative(Native Method)
  02-21 09:21:28.357: E/AndroidRuntime(6130):     at java.lang.reflect.Method.invoke(Method.java:511)
  02-21 09:21:28.357: E/AndroidRuntime(6130):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
  02-21 09:21:28.357: E/AndroidRuntime(6130):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
  02-21 09:21:28.357: E/AndroidRuntime(6130):     at dalvik.system.NativeStart.main(Native Method)
  02-21 09:21:28.357: E/AndroidRuntime(6130): Caused by: java.lang.NullPointerException
  02-21 09:21:28.357: E/AndroidRuntime(6130):     at com.taskey.me2team.StartHere.isOnline(StartHere.java:303)
  02-21 09:21:28.357: E/AndroidRuntime(6130):     at com.taskey.me2team.StartHere.onCreate(StartHere.java:124)
  02-21 09:21:28.357: E/AndroidRuntime(6130):     at android.app.Activity.performCreate(Activity.java:5276)
  02-21 09:21:28.357: E/AndroidRuntime(6130):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
  02-21 09:21:28.357: E/AndroidRuntime(6130):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2209)
  02-21 09:21:28.357: E/AndroidRuntime(6130):     ... 11 more
  </code></pre>
  
  <p>Heres the code:</p>
  
  <p>Splash Activity shows splash screen and then onto Main Activity</p>
  
  <pre><code>package com.mycompany.myappname;
  
  import android.os.Bundle;
  import android.os.Handler;
  import android.app.Activity;
  import android.content.Intent;
  
  public class SplashActivity extends Activity {
  
      // Splash screen timer
      private static int SPLASH_TIME_OUT = 1600;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_splash);
          //getWindow().getDecorView().getBackground().setDither(true);
  
          new Handler().postDelayed(new Runnable() {
  
              /*
               * Showing splash screen with a timer. This will be useful when you
               * want to show case your app logo / company
               */
  
              @Override
              public void run() {
  
                  Intent i = new Intent(SplashActivity.this, StartHere.class);
                  startActivity(i);
  
                  finish();
              }
          }, SPLASH_TIME_OUT);
      }
  
  }
  </code></pre>
  
  <p>Now my main actitivity is as follows</p>
  
  <pre><code>package com.mycompany.myappname;
  
  
  import android.annotation.SuppressLint;
  import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  import android.content.SharedPreferences;
  import android.content.SharedPreferences.Editor;
  import android.net.ConnectivityManager;
  import android.net.NetworkInfo;
  import android.os.Bundle;
  //import android.util.Log;
  import android.view.Gravity;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.webkit.WebChromeClient;
  import android.webkit.WebSettings;
  import android.webkit.WebView;
  import android.webkit.WebViewClient;
  import android.widget.Toast;
  
  @SuppressLint("SetJavaScriptEnabled")
  
  public class StartHere extends Activity {
  
      final Activity activity = this;
      MenuItem  menu_LogIn, menu_SignUp, go_Back, go_Forward;
  
      private SharedPreferences userCredentials;
      private Boolean isLoggedIn;
      private String m2tUser;
      private String webURL;
  
  
      WebView webView;
  
      public MyData getUser;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_start_here);
  
          getUser = ((MyData)getApplicationContext()); 
          userCredentials = getApplicationContext().getSharedPreferences("me2team", MODE_PRIVATE);
          isLoggedIn = userCredentials.getBoolean("LIStatus", false);
          m2tUser = userCredentials.getString("User", "username");
  
          if (!isLoggedIn)
          {
              Editor m2tEditor = userCredentials.edit();
              m2tEditor.putBoolean("PUStatus", false);
              m2tEditor.putString("Pswd", "5&amp;GEthtFE5");
              m2tEditor.commit();
              MyData setLoggedOff = ((MyData)getApplicationContext());
              setLoggedOff.setCredentialsUser(m2tUser);
              setLoggedOff.setStateOff();
              setLoggedOff.setPremiumUserOff();
  
              if (m2tUser.contains("username"))
                  webURL = getResources().getString(R.string.welcomeURL);         
              else
  
                  webURL = getResources().getString(R.string.splashURL);
          }
          else
          {
              MyData loggingOn = ((MyData)getApplicationContext());
                  loggingOn.setCredentialsUser(m2tUser);
                  loggingOn.setCredentialsPwd(userCredentials.getString("Pswd", "89798978"));
                  loggingOn.setStateOn();
                  boolean puStatus = userCredentials.getBoolean("PUStatus", false);
                  if (puStatus)
                      loggingOn.setPremiumUserOff();
                  else
                      loggingOn.setPremiumUserOn();
  
          }
  
  
          webView = (WebView) findViewById(R.id.webView1);
          webView.getSettings().setJavaScriptEnabled(true);
          webView.getSettings().setSavePassword(false);
          webView.getSettings().setSupportZoom(true);
          webView.getSettings().setBuiltInZoomControls(false); //as per Janet's request
          webView.getSettings().setUseWideViewPort(true);
          webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
          webView.setScrollbarFadingEnabled(false);
          webView.getSettings().setLoadWithOverviewMode(true);
          webView.setInitialScale(70);
  
          WebSettings settings = webView.getSettings();
          settings.setDomStorageEnabled(true);
  
          webView.loadUrl(webURL);
  
          webView.setWebChromeClient(new WebChromeClient() {
              public void onProgressChanged(WebView view, int progress)
              {
                  activity.setTitle("Loading...");
                  activity.setProgress(progress * 100);             
                  if(progress == 100)
                  {
                      activity.setTitle(R.string.app_name);
  
                  }
  
               }
          });
  
          webView.setWebViewClient(new WebViewClient() {
              @Override
              public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
              {
                  // Handle the error
              }
  
  
  
          });
  
          if (!isOnline())
          {
              Toast msg = Toast.makeText(StartHere.this,
                        "You dont seem to be connected to the Internet.", Toast.LENGTH_LONG);
               msg.setGravity(Gravity.CENTER, 0, 0);
               msg.show(); 
  
          }
  
  
          webView.loadUrl(webURL);        
  
      }
  
      public void goToTeamPage()
      {
  
          Intent intent = new Intent(this, TeamPage.class);
          startActivity(intent);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          super.onCreateOptionsMenu(menu);
          getMenuInflater().inflate(R.menu.start_here, menu);
          menu_LogIn = menu.findItem(R.id.currentlyLoggedOut);
          menu_SignUp = menu.findItem(R.id.signUp);
          go_Back = menu.findItem(R.id.goBack);
          go_Forward = menu.findItem(R.id.goForward);
          return true;
      }
  
      @Override
      public boolean onPrepareOptionsMenu(Menu menu) {
          super.onPrepareOptionsMenu(menu);
  
  
              menu_LogIn.setVisible(true);
              go_Back.setVisible(true);
              go_Forward.setVisible(true);
              menu_SignUp.setVisible(true);
  
  
          return true;
      }
  
  
      @Override
      public boolean onOptionsItemSelected( MenuItem item )
      {
          super.onOptionsItemSelected(item);
  
          switch (item.getItemId()) 
          {
          case R.id.currentlyLoggedOut:
          {
  
              Intent intent = new Intent(this, Me2TeamLogIn.class);
              startActivity(intent);
              return true;
          }
  
          case R.id.signUp:
          {
  
              Intent intent = new Intent(this, SignUp.class);
              startActivity(intent);
              return true;
          }
  
          case R.id.goBack:
          {
              if(webView.canGoBack() == true)
              {
                  webView.goBack();
              }
  
  
              return true;
          }
  
          case R.id.goForward:
          {
  
              if(webView.canGoForward() == true)
              {
              webView.goForward();
  
              }
  
  
              return true;
          }
  
          default:
          return super.onOptionsItemSelected(item);
          }
      }
  
      @Override
      protected void onStart()
      {
          //Log.wtf("TimV", "OnStart");
          super.onStart();
      }
  
      @Override
      protected void onResume()
      {
  
          //Log.wtf("TimV", "OnResume");
          if (isLoggedIn)
          {
              goToTeamPage();
          }
          super.onResume();
      }
  
      @Override
      protected void onPause()
      {
          //Log.wtf("TimV", "OnPause");
          super.onPause();
      }
  
  
      @Override
      protected void onRestart()
      {
      super.onRestart();
  
      if (!isOnline())
      {
          Toast msg = Toast.makeText(StartHere.this,
                    "You dont seem to be connected to the Internet.", Toast.LENGTH_LONG);
           msg.setGravity(Gravity.CENTER, 0, 0);
           msg.show(); 
      }
  
          MyData loginData = ((MyData)getApplicationContext());       
          isLoggedIn = loginData.getState();      
          if (isLoggedIn)
          {
          //  Log.wtf("TimV", "going to team page");
  
              Intent intent = new Intent(this, TeamPage.class);
              startActivity(intent);
          }
          else
              {
          //  Log.wtf("TimV", "going to splash page");
              webURL = getResources().getString(R.string.splashURL);
              webView.loadUrl(webURL);
  
              }               
  
      }
  
  
      public boolean isOnline() {
  
          ConnectivityManager connMgr = (ConnectivityManager) 
                  getSystemService(Context.CONNECTIVITY_SERVICE);
          NetworkInfo networkInfo = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); 
          boolean isWifiConn = networkInfo.isConnected();
          networkInfo = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
          boolean isMobileConn = networkInfo.isConnected();
  
          if (isWifiConn)
              return true;
          else
          {   
              if (isMobileConn)
                  return true;
              else
                  return false;
          }
      }
  
  }
  </code></pre>
  
  <p>This issue really has me stumped as all googling on the issue has not provided answers as yet.</p>