title: Error in android.os.Process.killProcess(android.os.Process.myPid());
body: <p>Ive got an error when i call this android.os.Process.killProcess(android.os.Process.myPid());
  My logcat says it is unable to start activity. as my understanding using kill process is to kill task that is running but when i use this it shows that it is starting to call another activity. 
  here is my code:</p>
  
  <pre><code>AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(S_2nd_LoginActivity.this);
          alertDialogBuilder.setTitle("Are you sure you want to cancel?")
                            .setCancelable(false)
                            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int id) {
  
  
                                  android.os.Process.killProcess(android.os.Process.myPid());
  
  
                              }
                          })
                            .setNegativeButton("No", new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int id) {
                                  dialog.dismiss();
                              }
                            });
  
          AlertDialog alertDialog = alertDialogBuilder.create();
          alertDialog.show();
  </code></pre>
  
  <p>here is my logcat:</p>
  
  <pre><code>03-04 18:28:43.805: E/AndroidRuntime(19417): java.lang.RuntimeException: Unable to  start activity ComponentInfo{ph.com.example.Project/ph.com.example.Project.MainActivity}: java.lang.NullPointerException
  03-04 18:28:43.805: E/AndroidRuntime(19417):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1815)
  03-04 18:28:43.805: E/AndroidRuntime(19417):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
  03-04 18:28:43.805: E/AndroidRuntime(19417):    at android.app.ActivityThread.access$500(ActivityThread.java:122)
  03-04 18:28:43.805: E/AndroidRuntime(19417):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
  03-04 18:28:43.805: E/AndroidRuntime(19417):    at android.os.Handler.dispatchMessage(Handler.java:99)
  03-04 18:28:43.805: E/AndroidRuntime(19417):    at android.os.Looper.loop(Looper.java:132)
  03-04 18:28:43.805: E/AndroidRuntime(19417):    at android.app.ActivityThread.main(ActivityThread.java:4123)
  03-04 18:28:43.805: E/AndroidRuntime(19417):    at java.lang.reflect.Method.invokeNative(Native Method)
  03-04 18:28:43.805: E/AndroidRuntime(19417):    at java.lang.reflect.Method.invoke(Method.java:491)
  03-04 18:28:43.805: E/AndroidRuntime(19417):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
  03-04 18:28:43.805: E/AndroidRuntime(19417):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
  03-04 18:28:43.805: E/AndroidRuntime(19417):    at dalvik.system.NativeStart.main(Native Method)
  03-04 18:28:43.805: E/AndroidRuntime(19417): Caused by: java.lang.NullPointerException
  03-04 18:28:43.805: E/AndroidRuntime(19417):    at ph.com.example.Project.MainActivity.get_Territory(MainActivity.java:169)
  03-04 18:28:43.805: E/AndroidRuntime(19417):    at ph.com.example.Project.MainActivity.onCreate(MainActivity.java:74)
  03-04 18:28:43.805: E/AndroidRuntime(19417):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
  03-04 18:28:43.805: E/AndroidRuntime(19417):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1779)
  </code></pre>
  
  <p>here is my method of get Territory:</p>
  
  <pre><code>public void get_Territory() {
      String territory = String.valueOf(LoginActivity.g_territory);
  
      lbl_user.setText(LoginActivity.txt_username.getText().toString());
  
      String s = l_databaseHandler.get_territoryCode(territory);
      String f = l_databaseHandler.get_doctorFname(s);
      String l = l_databaseHandler.get_doctorLname(s);
  
      Cursor cursorAllDetails = l_databaseHandler.get_all_sameDoctorname(f, l);
  
      if (cursorAllDetails.getCount() != 0){
          fillData(cursorAllDetails);
      }else{
          save_territory();
      }
  
  }
  </code></pre>
  
  <p>and i call this method this way on my onCreate:</p>
  
  <pre><code>    @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      l_databaseHandler = new DatabaseHandler(this);
      if (l_databaseHandler != null) {
          l_databaseHandler.close();
          l_databaseHandler.createDB();
      }
  
      Constants.from_add = false;
      Constants.from_edit = false;
      Constants.from_view = false;
  
      cast_views();
  
      get_Territory();
  
      log_out();
  
            }
  </code></pre>
  
  <p>Any help will be appreciated, thank you. I'd use this before and i use it again the same way, i just dont get it why it is acting this way.</p>