Android Open Source - Android-Custom-Notification-Tutorial Notification View






From Project

Back to project page Android-Custom-Notification-Tutorial.

License

The source code is released under:

Apache License

If you think the Android project Android-Custom-Notification-Tutorial listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.androidbegin.notificationtutorial;
//from  w ww  .  j a  v a 2  s .  co  m
import android.app.Activity;
import android.app.NotificationManager;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

public class NotificationView extends Activity {
  String title;
  String text;
  TextView txttitle;
  TextView txttext;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.notificationview);
    
    // Create Notification Manager
    NotificationManager notificationmanager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    // Dismiss Notification
    notificationmanager.cancel(0);
    
    // Retrive the data from MainActivity.java
    Intent i = getIntent();

    title = i.getStringExtra("title");
    text = i.getStringExtra("text");

    // Locate the TextView
    txttitle = (TextView) findViewById(R.id.title);
    txttext = (TextView) findViewById(R.id.text);

    // Set the data into TextView
    txttitle.setText(title);
    txttext.setText(text);
  }
}




Java Source Code List

com.androidbegin.notificationtutorial.MainActivity.java
com.androidbegin.notificationtutorial.NotificationView.java