title: startActivity() function error LogCat and AndroidManifest.xml included
body: <blockquote>
    <p>When i click on the button "OK", it force closes. There is something wrong with the startActivity() function.When i click on the ok button, the app force closes and the LogCat throws the following errors enclosed. There is something wrong with the startactivity() method in MainActivity.java</p>
  </blockquote>
  
  <p><strong>MainActivity.java</strong>  </p>
  
  <pre><code>package com.location.sensor;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.content.res.Resources.NotFoundException;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.view.animation.Animation;
  import android.view.animation.AnimationUtils;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  
  public class MainActivity extends Activity {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
              Button btn=(Button) findViewById(R.id.btn_OK);
              Animation anim= AnimationUtils.loadAnimation(getApplicationContext(), R.anim.jump);
              btn.startAnimation(anim);
              btn.setOnClickListener(new View.OnClickListener() {
  
                  @Override
                  public void onClick(View v) {
                      // TODO Auto-generated method stub
                      Animation anim= AnimationUtils.loadAnimation(getApplicationContext(), R.anim.jump);
                      anim.setDuration(3000);
                      v.startAnimation(anim);
                      TextView n=new TextView(getBaseContext());
                      EditText txt=(EditText) findViewById(R.id.txt_username);
                      //Animation anim= AnimationUtils.loadAnimation(getApplicationContext(), R.anim.jump);
                      //n.startAnimation(anim);
                      String s=txt.getText().toString();
                      n.setText(s);
                      n.setBackgroundResource(R.drawable.icn);
                      //Intent i=new Intent("com.location.pendintent");
                      //Bundle extras=new Bundle();
                      //extras.putString("alarm", s);
                      //i.putExtras(extras);
                      try {
                          startActivity(new Intent("com.hello.loc"));
                      } catch (Exception e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                          Log.d("service", "Caught here!");
                      }
  
                  }
              });
  
      }
  }
  </code></pre>
  
  <p><strong>NotificationClass.java</strong></p>
  
  <pre><code>package com.location.sensor;
  
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.app.Dialog;
  import android.content.DialogInterface;
  import android.os.Bundle;
  import android.view.View;
  import android.view.Window;
  import android.widget.Button;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class NotificationClass extends Activity {
      public void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          //requestWindowFeature(Window.FEATURE_NO_TITLE);
          //String data=getIntent().getExtras().getString("alarm").toString();
          TextView tv=(TextView) findViewById(R.id.txt_pendint);
          Button btn=(Button) findViewById(R.id.btn_cancel);
          //tv.setText(data);
          btn.setOnClickListener(new View.OnClickListener() {
  
              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  showDialog(0);
  
              }
          });
          setContentView(R.layout.notif);
      }
  protected Dialog onCreateDialog(int id)
  {
      switch(id)
      {
      case 0:
  
          return new AlertDialog.Builder(this)
                  .setIcon(R.drawable.excl_mark)
                  .setTitle("Do you want to Cancel?")
                  .setPositiveButton("Yes",new DialogInterface.OnClickListener() {
  
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          // TODO Auto-generated method stub
                          finish();
                      }
                  })
                  .setNegativeButton("No",new DialogInterface.OnClickListener() {
  
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          // TODO Auto-generated method stub
                          Toast.makeText(getBaseContext(), "Cancel Clicked!", Toast.LENGTH_LONG).show();
                      }
                  })
                  .create();
      }
      return null;
  
  }
  }
  </code></pre>
  
  <p><strong>AndroidManifest.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.location.sensor"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk android:minSdkVersion="10"/&gt;
  
      &lt;application
          android:icon="@drawable/gps1"
          android:label="@string/app_name" &gt;
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/app_name" &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=".NotificationClass"
              android:label="YOU ARE IN PROXIMITY AREA!!!"&gt;
              &lt;intent-filter&gt;
                 &lt;action android:name="com.hello.loc"/&gt; 
                 &lt;category  android:name="android.intent.category.DEFAULT" /&gt; 
               &lt;/intent-filter&gt;   
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>LogCat</strong></p>
  
  <pre><code>08-01 00:42:20.665: E/Trace(808): error opening trace file: No such file or directory (2)
  08-01 00:42:51.165: E/AndroidRuntime(808): FATAL EXCEPTION: main
  08-01 00:42:51.165: E/AndroidRuntime(808): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.location.sensor/com.location.sensor.NotificationClass}: java.lang.NullPointerException
  08-01 00:42:51.165: E/AndroidRuntime(808):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
  08-01 00:42:51.165: E/AndroidRuntime(808):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
  08-01 00:42:51.165: E/AndroidRuntime(808):  at android.app.ActivityThread.access$600(ActivityThread.java:130)
  08-01 00:42:51.165: E/AndroidRuntime(808):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
  08-01 00:42:51.165: E/AndroidRuntime(808):  at android.os.Handler.dispatchMessage(Handler.java:99)
  08-01 00:42:51.165: E/AndroidRuntime(808):  at android.os.Looper.loop(Looper.java:137)
  08-01 00:42:51.165: E/AndroidRuntime(808):  at android.app.ActivityThread.main(ActivityThread.java:4745)
  08-01 00:42:51.165: E/AndroidRuntime(808):  at java.lang.reflect.Method.invokeNative(Native Method)
  08-01 00:42:51.165: E/AndroidRuntime(808):  at java.lang.reflect.Method.invoke(Method.java:511)
  08-01 00:42:51.165: E/AndroidRuntime(808):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
  08-01 00:42:51.165: E/AndroidRuntime(808):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  08-01 00:42:51.165: E/AndroidRuntime(808):  at dalvik.system.NativeStart.main(Native Method)
  08-01 00:42:51.165: E/AndroidRuntime(808): Caused by: java.lang.NullPointerException
  08-01 00:42:51.165: E/AndroidRuntime(808):  at com.location.sensor.NotificationClass.onCreate(NotificationClass.java:23)
  08-01 00:42:51.165: E/AndroidRuntime(808):  at android.app.Activity.performCreate(Activity.java:5008)
  08-01 00:42:51.165: E/AndroidRuntime(808):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
  08-01 00:42:51.165: E/AndroidRuntime(808):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
  08-01 00:42:51.165: E/AndroidRuntime(808):  ... 11 more
  </code></pre>
  
  <p><strong>notif.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical"&gt;
   &lt;Button
       android:text="Cancel"
       android:id="@+id/btn_cancel"
       android:layout_height="wrap_content"
       android:layout_width="fill_parent"
       android:background="#FF4000"
       /&gt;
   &lt;LinearLayout 
       android:padding="5px"
       android:orientation="vertical"&gt;
       &lt;TextView 
           android:id="@+id/txt_pendint"
           android:textSize="18px"
           android:text="No text Added"
           android:textColor="#A9F5E1"
           android:background="#0B3B39"/&gt;
   &lt;/LinearLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>