Android UI How to - Alert user with notification service








Question

We would like to know how to alert user with notification service.

Answer

/* w w w  .  j a v  a 2s.  c om*/
import android.app.Activity;
import android.app.NotificationManager;
import android.os.Bundle;
import android.widget.TextView;

public class Main extends Activity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TextView tv = new TextView(this);
    tv.setText("alert");
    setContentView(tv);

    NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    nm.cancel(1234);

  }
}