Here is a simple example for a message notification with a sound as when you click a button.
package com.notify;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class notify extends Activity {
private NotificationManager mNotificationManager;
private int SIMPLE_NOTFICATION_ID;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
final Notification notifyDetails = new Notification(R.drawable.icon,"New Alert, Click Me!",System.currentTimeMillis());
long[] vibrate = {100,100,200,300};
notifyDetails.vibrate = vibrate;
notifyDetails.defaults =Notification.DEFAULT_ALL;
Context context = getApplicationContext();
Button start = (Button)findViewById(R.id.btn_showsample);
Button cancel = (Button)findViewById(R.id.btn_clear);
start.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Context context = getApplicationContext();
CharSequence contentTitle = "Schogini Systems. Simple Notification";
CharSequence contentText = "Get back to Application on clicking me";
Intent notifyIntent = new Intent(context, notify.class);
PendingIntent intent =
PendingIntent.getActivity(notify.this, 0,
notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
notifyDetails.setLatestEventInfo(context, contentTitle, contentText, intent);
mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);
}
});
cancel.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mNotificationManager.cancel(SIMPLE_NOTFICATION_ID);
}
});
}
}



