title: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo: java.lang.NullPointerException
body: <p>When I want to move on on other activity I have this Exception:</p>
  
  <pre><code>java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{ua.kbv.adviser/ua.kbv.adviser.AdviceWithText}: java.lang.NullPointerException
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
      at android.app.ActivityThread.access$600(ActivityThread.java:141)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:137)
      at android.app.ActivityThread.main(ActivityThread.java:5041)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:511)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
      at dalvik.system.NativeStart.main(Native Method)
  Caused by: java.lang.NullPointerException
      at android.content.ContextWrapper.getResources(ContextWrapper.java:89)
      at android.view.ContextThemeWrapper.getResources(ContextThemeWrapper.java:78)
      at ua.kbv.adviser.AdviceWithText.&lt;init&gt;(AdviceWithText.java:18)
      at java.lang.Class.newInstanceImpl(Native Method)
      at java.lang.Class.newInstance(Class.java:1319)
      at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
      at android.app.ActivityThread.access$600(ActivityThread.java:141)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:137)
      at android.app.ActivityThread.main(ActivityThread.java:5041)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:511)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
      at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Manifest:</p>
  
  <p></p>
  
  <pre><code>&lt;application android:allowBackup="true"
      android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
      android:theme="@style/AppTheme"&gt;
  
      &lt;activity android:name=".MainActivity"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN"/&gt;
              &lt;category android:name="android.intent.category.LAUNCHER"/&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
      &lt;activity android:name=".AdviceWithText"/&gt;
      &lt;activity android:name=".AdviceWithoutText"/&gt;
      &lt;supports-screens
          android:smallScreens="true"
          android:normalScreens="true"
          android:largeScreens="true"
          android:anyDensity="true"
          /&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>Main Activity:</p>
  
  <pre><code>public class MainActivity extends Activity{
  
      private static long back_pressed;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main_layout);
      }
  
      public void clickOnGetAdvice(View view){
  
  
          AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
  
          builder.setTitle(R.string.builderTitle)
                  .setMessage(R.string.builderMessage)
                  .setCancelable(true)
                  .setIcon(R.mipmap.ic_action)
                  .setNeutralButton(R.string.neutralButton, new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          Intent intent = new Intent(MainActivity.this, AdviceWithText.class);
                          startActivity(intent);
                          dialog.dismiss();
                      }
                  })
                  .setPositiveButton(R.string.positivebutton, new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          Intent intent = new Intent(MainActivity.this, AdviceWithoutText.class);
                          startActivity(intent);
                          dialog.dismiss();
                      }
                  });
  
          AlertDialog alert = builder.create();
          alert.show();
      }
  
      @Override
      public void onBackPressed() {
          if (back_pressed + 2000 &gt; System.currentTimeMillis()) {
              super.onBackPressed();
          } else {
              Toast.makeText(getBaseContext(), R.string.exitToast, Toast.LENGTH_SHORT).show();
          }
  
          back_pressed = System.currentTimeMillis();
  
      }
  
      public void clickOnAbout(View view){
          AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
          builder.setTitle(R.string.builderAboutTitle)
                  .setMessage(R.string.builderMessageAbout)
                  .setCancelable(true)
                  .setIcon(R.mipmap.ic_action_info)
                  .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          dialog.dismiss();
                      }
                  });
  
          AlertDialog alertDialog = builder.create();
          alertDialog.show();
  
      }
  
          @Override
          protected void onDestroy () {
              super.onDestroy();
              System.exit(0); 
          }
  }
  </code></pre>
  
  <p>Recieving Activity:</p>
  
  <pre><code>public class AdviceWithText extends Activity{
  
       TextView answer;
       private EditText question;
       String [] advices = getResources().getStringArray(R.array.advices);
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.with_layout);
      }
  
      public void getAdvice(View view){
          answer = (TextView) findViewById(R.id.answerText);
          question = (EditText) findViewById(R.id.questionWith);
          String text = question.getText().toString();
          int rand = (int) Math.floor(Math.random()* advices.length);
          if(text.equals("")){
              Toast.makeText(getApplicationContext(),R.string.toastWith, Toast.LENGTH_LONG).show();
          } else if(text.matches("[0-9]+")) {
              Toast.makeText(getApplicationContext(),R.string.toastWithSecond, Toast.LENGTH_LONG).show();
          } else {
              answer.setText(advices[rand]);
          }
      }
  
      @Override
      public void onBackPressed() {
          finish();
      }
  
      public void reset(View view){
          question = (EditText) findViewById(R.id.questionWith);
          question.setText("");
          answer.setText("");
  
      }
  
  }
  </code></pre>