title: Android: Currency converter crashes when trying to convert
body: <p>First time programmer here. So I'm creating a converter for weights using Eclipse where I input a value and use 2 spinners to choose the units and display the result on the next activity. My converter crashes whenever it tries to convert the input value. I had no problems showing my input value onto my next activity but whenever I enable the conversion logic it crashes when I press the convert button. </p>
  
  <p>My Main Activity doing the conversions and passing to other intent</p>
  
  <pre><code>package com.example.currencyconverter2;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.ArrayAdapter;
  import android.widget.EditText;
  import android.widget.Spinner;
  
  public class MainActivity extends Activity {
   Spinner fromCurrency;
   Spinner toCurrency;
   public static String final1;
   double result;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
      if (id == R.id.action_settings) {
          return true;
      }
      return super.onOptionsItemSelected(item);
  }
  
  
  /*protected void onResume{
      super.onResume();
      setUpSpinnerData();
  }*/
  //Sets the data for the Spinner to display
  public void setSpinnerData(){
      fromCurrency = (Spinner)findViewById(R.id.from_currency);
      toCurrency = (Spinner)findViewById(R.id.to_currency);
      ArrayAdapter &lt;String&gt; from = new ArrayAdapter&lt;String&gt;(this,R.array.currencySpinnerChoices,android.R.layout.simple_list_item_1);
      ArrayAdapter &lt;String&gt; to = new ArrayAdapter&lt;String&gt;(this,R.array.currencySpinnerChoices,android.R.layout.simple_list_item_1);
      fromCurrency.setAdapter(from);
      toCurrency.setAdapter(to);
      }
  
  //New intent on button press with inserted data 
   public void showResult(View v){
  
     Intent i = new Intent(this, MainResultActivity.class);
     EditText editconvert = (EditText) findViewById(R.id.amount);
     String string1 = editconvert.getText().toString();
     //double value = Double.parseDouble(string1);
  
     int cho1 = fromCurrency.getSelectedItemPosition();
     int cho2 = toCurrency.getSelectedItemPosition();
     double value = Double.parseDouble(editconvert.getText().toString());
  
     double ratio[] = {1.0f, 0.001f, 1.0e-6f, 1.0e-9f};
     double result = value / ratio[cho1] * ratio[cho2];
  
     i.putExtra(final1, result);
     startActivity(i);       
    }  
  }
  </code></pre>
  
  <p>My onCreate method in my other activity showing the result</p>
  
  <pre><code>  protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main_result);
  
      //MainActivity.class.getIntent();
      Intent intent = getIntent();
  
      double value = intent.getDoubleExtra(MainActivity.final1,0);        
      TextView tv = (TextView)findViewById(R.id.result_value);
  
      tv.setText(value+" ");      
  }
  </code></pre>
  
  <p><strong>My LogCat</strong></p>
  
  <pre><code>12-02 05:50:40.002: E/AndroidRuntime(1528): FATAL EXCEPTION: main
  12-02 05:50:40.002: E/AndroidRuntime(1528): Process: com.example.currencyconverter2, PID: 1528
  12-02 05:50:40.002: E/AndroidRuntime(1528): java.lang.IllegalStateException: Could not execute method of the activity
  12-02 05:50:40.002: E/AndroidRuntime(1528):     at android.view.View$1.onClick(View.java:3823)
  12-02 05:50:40.002: E/AndroidRuntime(1528):     at android.view.View.performClick(View.java:4438)
  12-02 05:50:40.002: E/AndroidRuntime(1528):     at    android.view.View$PerformClick.run(View.java:18422)
  12-02 05:50:40.002: E/AndroidRuntime(1528):     at android.os.Handler.handleCallback(Handler.java:733)
  12-02 05:50:40.002: E/AndroidRuntime(1528):     at android.os.Handler.dispatchMessage(Handler.java:95)
  12-02 05:50:40.002: E/AndroidRuntime(1528):     at android.os.Looper.loop(Looper.java:136)
  12-02 05:50:40.002: E/AndroidRuntime(1528):     at android.app.ActivityThread.main(ActivityThread.java:5017)
  12-02 05:50:40.002: E/AndroidRuntime(1528):     at java.lang.reflect.Method.invokeNative(Native Method)
  12-02 05:50:40.002: E/AndroidRuntime(1528):     at java.lang.reflect.Method.invoke(Method.java:515)
  12-02 05:50:40.002: E/AndroidRuntime(1528):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
  12-02 05:50:40.002: E/AndroidRuntime(1528):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
  12-02 05:50:40.002: E/AndroidRuntime(1528):     at dalvik.system.NativeStart.main(Native Method)
  12-02 05:50:40.002: E/AndroidRuntime(1528): Caused by: java.lang.reflect.InvocationTargetException
  12-02 05:50:40.002: E/AndroidRuntime(1528):     at java.lang.reflect.Method.invokeNative(Native Method)
  12-02 05:50:40.002: E/AndroidRuntime(1528):     at java.lang.reflect.Method.invoke(Method.java:515)
  12-02 05:50:40.002: E/AndroidRuntime(1528):     at android.view.View$1.onClick(View.java:3818)
  12-02 05:50:40.002: E/AndroidRuntime(1528):     ... 11 more
  12-02 05:50:40.002: E/AndroidRuntime(1528): Caused by: java.lang.NullPointerException
  12-02 05:50:40.002: E/AndroidRuntime(1528):     at com.example.currencyconverter2.MainActivity.showResult(MainActivity.java:68)
  12-02 05:50:40.002: E/AndroidRuntime(1528):     ... 14 more
  </code></pre>
  
  <p>Pretty new so I don't understand logcat errors, can anyone explain?</p>