android的通知代码


Notification code for android

我想在android中创建通知和警报。我知道我的PHP正在运行,但我是安卓编程的初学者{//dteam_id";$query.=",s.dt_start_timeTHEN'30'";$query.="WHEN‘01:00:00’THEN‘1'";$query.="s.c_user_id=ms.c_user_id";$query.="AND s.c_team_id=ms.c_team_id";$query.="AND ms.c_user_id='".$userID."'";$query.="WHERE s.c_user_id='".$userID."'";$query.="AND s.c_entry=1";$query.="AND s.t_alert>=CURRENT_TIMESTAMP()";$query.="和(DATE_ADD(CURDATE(),间隔7天))";$query.="按s.t_alert订购";$query.="限制64";$result=mysql_query($query);

            $totalRowsCount = mysql_num_rows($result);
            if($totalRowsCount == 0)
            { 
                sendResponse(400, 'Record Not Found'); 
                return false;
            }
            else
            {
                while( $row2 = mysql_fetch_array( $result ) )
                {
                    $data = array(
                        'teamID' => ($row2["c_team_id"] == "" ) ? "" : $row2["c_team_id"],
                        'startTime' => ($row2["dt_start_time"]

}

试试这个:

private void generateNotification(Context context, String message) {
int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
String appname = context.getResources().getString(R.string.app_name);
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
Notification notification;
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
new Intent(context, myactivity.class), 0);
// To support 2.3 os, we use "Notification" class and 3.0+ os will use
// "NotificationCompat.Builder" class.
if (currentapiVersion < android.os.Build.VERSION_CODES.HONEYCOMB) {
notification = new Notification(icon, message, 0);
notification.setLatestEventInfo(context, appname, message,
contentIntent);
notification.flags = Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, notification);
} else {
NotificationCompat.Builder builder = new NotificationCompat.Builder(
context);
notification = builder.setContentIntent(contentIntent)
.setSmallIcon(icon).setTicker(appname).setWhen(0)
.setAutoCancel(true).setContentTitle(appname)
.setContentText(message).build();
notificationManager.notify(0 , notification);
}
}

希望这能有所帮助。