標題: 幾個輸出訊息的方式 [打印本頁] 作者: xyaw 時間: 2013-8-1 10:31 標題: 幾個輸出訊息的方式 debug時加入訊息可以幫助瞭解程式運行情形
android SDK中提供了Log類別輸出訊息
Log.v("log_msg", "verbose: this is debug_message");
Log.d("log_msg", "debug: this is debug_message");
Log.i("log_msg", "info: this is debug_message");
Log.w("log_msg", "warn: this is debug_message");
Log.e("log_msg", "error: this is debug_message");
Log類別中的訊息有五種 , 可以根據重要程度自行決定該使用哪一種
在Eclipse的Logcat視窗中 , 就能夠看到這些訊息
並且不同訊息有著不同的顏色:
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(ttile)
.setContentText(ttext2);
Intent resultIntent = new Intent(this, notify_activity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
// Adds the back stack
stackBuilder.addParentStack(notify_activity.class);
// Adds the Intent to the top of the stack
stackBuilder.addNextIntent(resultIntent);
// Gets a PendingIntent containing the entire back
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0,PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1, mBuilder.build());