我想在收到短信时显示通知...但是无法执行,因为我无法更改为静态的'StartService(intente);' 我应该更改我的代码吗?
public override void OnReceive(Context context, Intent intent)
{
if (intent.HasExtra("pdus"))
{
var smsArray = (Java.Lang.Object[])intent.Extras.Get("pdus");
string address = "";
string message = "";
foreach (var item in smsArray)
{
var sms = SmsMessage.CreateFromPdu((byte[])item);
_message = sms.MessageBody;
_sender = sms.OriginatingAddress;
}
if (_sender.Contains(txtCarNumber.Text.Substring(1, 10)))
{
MsgReceived(_message, context);
SwitchClass.StopProgress();
// For Show on Notification
var intente = new Intent(context, typeof(NotificationsCommand));
intente.PutExtra("Command", "TurnOff");
StartService(intente); //=> here compiler say should be Static
// End
}
}
}