title: NullPointerException while Encoding a Url android
body: <p>I am trying to encode a certain url by using the following code:</p>
  
  <pre><code>myWebView = (WebView)findViewById(R.id.webView1);
  
      Login myLogin = new Login();
      url = myLogin.AuthUrl;
      try 
      {
  
          String encodedUrl = URLEncoder.encode(url, "UTF-8");
      } 
      catch (UnsupportedEncodingException e) 
      {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
      myWebView.getSettings().setJavaScriptEnabled(true);
      myWebView.loadUrl(url);
      myWebView.setWebViewClient(new MyWebViewClient());
  </code></pre>
  
  <p>But I get the following error:-</p>
  
  <pre><code> 02-27 15:21:57.054: E/AndroidRuntime(1586): FATAL EXCEPTION: main
      02-27 15:21:57.054: E/AndroidRuntime(1586): Caused by: java.lang.NullPointerException
      02-27 15:21:57.054: E/AndroidRuntime(1586): at libcore.net.UriCodec.encode(UriCodec.java:132)
      02-27 15:21:57.054: E/AndroidRuntime(1586): at java.net.URLEncoder.encode(URLEncoder.java:57)
      02-27 15:21:57.054: E/AndroidRuntime(1586): at com.abcdef.abcd.Details.onCreate(Details.java:42)
  </code></pre>
  
  <p>What could be going wrong?
  Thanks for any help.</p>