我 通过 BroadcastReceiver 来拦截短信,并设置了优先级,应用程序的优先级比系统的要高,但此时但我拦截到短信时,我怎么通知我的应用程序我拦截到短信了,也就是怎么弄个Notification来通知我的应用程序来短信了呢?我在 public smsBroadcast extends BroadcastReceiver{
}
这个类中直接弄个通知不行啊,在用getSystemService获取 NotificationManager对象时报错,说我getSystemService这个方法在类smsBroadcast 中不可用。大家给个建议怎么设置这个Notification通知
}
这个类中直接弄个通知不行啊,在用getSystemService获取 NotificationManager对象时报错,说我getSystemService这个方法在类smsBroadcast 中不可用。大家给个建议怎么设置这个Notification通知
// TODO Auto-generated method stub
NotificationManager myNoti=(NotificationManager)context.getSystemService(Service.NOTIFICATION_SERVICE);
Notification myNotification=new Notification();
myNotification.icon=R.drawable.icon;
myNotification.tickerText="启动Activity";
Intent myIntent=new Intent(context,Activity1.class);
PendingIntent pi=PendingIntent.getActivity(context, 0, myIntent, 0);
myNotification.setLatestEventInfo(context, "提示","启动Activity", pi);
myNoti.notify();楼主试试吧!
}