title: how to show to battery status on text view?
body: <p>Actually i am trying to make an android app to display a text when the battery becomes 50% ,m using text view to display the msg,but while loading the app it gets unfortunately stops.</p>
  
  <p>here is my code:</p>
  
  <p>Java file.</p>
  
  <pre><code>package com.example.abhi.batteryalarm;
  
  import android.content.Intent;
  import android.os.BatteryManager;
  import android.support.v7.app.ActionBarActivity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.widget.TextView;
  
  
  public class Battery_Alarm extends ActionBarActivity {
      Intent batteryStatus;
      TextView txtView;
      String hello;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_battery__alarm);
          txtView=(TextView)findViewById(R.id.txtView);
          hello="This is my first project";
  
          int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
          if (level==50)
          {
              txtView.setText(hello);
          }
      }
  
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.menu_battery__alarm, 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();
  
          //noinspection SimplifiableIfStatement
          if (id == R.id.action_settings) {
              return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  </code></pre>
  
  <p>}</p>
  
  <p>activity file:</p>
  
  <pre><code> &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
      android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".Battery_Alarm"&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="hello"
          android:textSize="62sp"
          android:id="@+id/txtView"
          android:layout_centerHorizontal="true"
          android:layout_marginBottom="125dp" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>What things i need to do?</p>