たぼさんの部屋

いちょぼとのんびり

MyNotificationクラス(以前作っていたもの)

MyNotification.java

package info.kamogashira.notification;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
/**
 * 
 * @author kamogashiratsuyoshi
 * @使い方 
 * notification = new Notification(Class className); <br/>
 * notification.show(Context context, int iconID , String ticker , String title , String message);
 * @return void
 * 
 */
public class MyNotification {
	Class<?> className;
	public MyNotification(Class<?> className){
		this.className = className;
	}
	
	public  void show(Context context  , int iconID , String ticker , String title , String message){
		NotificationManager nm;
		nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
		
		Notification notification = new Notification(iconID , ticker , System.currentTimeMillis());
		int requestCode = 0;
		int flags = 0;
		
		Intent intent = new Intent(context , className);
		PendingIntent pendingIntent = PendingIntent.getActivity(context, requestCode, intent, flags);
		notification.setLatestEventInfo(context, title, message, pendingIntent);
		
		nm.cancel(0);
		
		nm.notify(0 , notification);
	}
}