안드로이드 개발 질문/답변
(글 수 45,052)
sms수신시
특정번호에 대해서
norification을 하고
그이후의 activity를 연결하려고 하는데
특정sms번호 식별하고 notification이 일어나지만
norification이후
창에서 선택후 지정된 activity로 이동이 되지 않고 있습니다...^^
어느부분을 고쳐주는것이 좋을까요...^^
조언을 부탁드립니다.
public class Sms extends Activity {
private static final int NOTIFY_1 = 0x1001;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
BroadcastReceiver incomingBR = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
String message = null;
String sender = null;
if (bundle != null) {
Object pdus[] = (Object[]) bundle.get("pdus");
for (Object pdu : pdus) {
SmsMessage msg = SmsMessage.createFromPdu((byte[]) pdu);
message = msg.getMessageBody();
sender = msg.getOriginatingAddress();
}
TextView incomingSMS = (TextView) findViewById(R.id.TextView01);
incomingSMS.setText(message + "\nFrom: " + sender);
}
//sms확인서비스
if (sender.equals("1319")){
NotificationManager notifier =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notify =
new Notification(R.drawable.icon,"도우미",System.currentTimeMillis());
notify.flags |=Notification.FLAG_AUTO_CANCEL;
notify.vibrate = new long[] {200,200,600,600,100,100,400,400};
Intent intent2 = new Intent(Sms.this, Db.class);
intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent launchIntent=
PendingIntent.getActivity(Sms.this, 0,intent2,0);
notify.setLatestEventInfo(Sms.this, "저장", "알림", launchIntent);
notify.number =1;
notifier.notify(NOTIFY_1,notify);
}
}
};
IntentFilter incomingIF =
new IntentFilter("android.provider.Telephony.SMS_RECEIVED");
registerReceiver(incomingBR, incomingIF);
}
}