我做短信应用。这是类接收短信:
public class TerimaSMS extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
Object messages[] = (Object[]) bundle.get("pdus");
SmsMessage smsMessage[] = new SmsMessage[messages.length];
for (int n = 0; n < messages.length; n++) {
smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages[n]);
}
// show first message
Toast toast = Toast.makeText(context,
"SMS Received : " + smsMessage[0].getMessageBody(), Toast.LENGTH_LONG);
toast.show();
}
}
如何将吐司更改为状态栏中的通知?谢谢!