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()); } }
广播中的提示方式NotificationManager
最新推荐文章于 2018-07-09 10:56:46 发布