1. 程式人生 > >廣播中的提示方式NotificationManager

廣播中的提示方式NotificationManager

public  class MyBroadcastReveiver extends BroadcastReceiver {
    private NotificationManager manager;
    public void onReceive(Context context, Intent intent){
       manager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
        String string = intent.getStringExtra("name"
); //Toast.makeText(context,"Hello world0" + string,Toast.LENGTH_SHORT).show(); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setTicker("廣播來了"); builder.setSmallIcon(R.drawable.back_bg); builder.setContentTitle("沒有網了"); builder.setContentText("Wifi
掉了"+string); manager.notify(1001,builder.build()); } }