Notification 改新寫法
Notification Noti=new Notification(); Intent i = new Intent(this, MainActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); Noti.icon = R . drawable . notification_icon ; // notification icon id Noti.tickerText=mc.getResources().getString(R.string.app_name); Noti.when=System.currentTimeMillis(); Noti.flags=Notification.FLAG_ONGOING_EVENT; // setLatestEventInfo 已被放棄 Noti.setLatestEventInfo( mc, mc.getResources().getString( "My notification" ), mc.getResources().getString( "Hello World!" ) , PendingIntent.getActivity(this, 0,i, 0) ); NotificationManager myNM = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE); myNM.notify(0,Noti); 改成如下 NotificationCompat . Builder mBuilder = new NotificationCompat . Builder ( this ) ...