廣播中的提示方式NotificationManager
阿新 • • 發佈:2019-01-22
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()); } }