I was trying to make an app that automatically detects the OTP send via the default Android messaging app -
here code:
btnsend.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { final string sentotp = randomnum(); if (!etnumber.gettext().tostring().trim().equals("")) { uri uri = uri.parse("smsto:" + etnumber.gettext().tostring().trim()); intent smsintent = new intent(intent.action_sendto, uri); smsintent.setflags(intent.flag_activity_new_task); smsintent.putextra("sms_body", sentotp); startactivity(smsintent); inish(); intent = new intent(sendactivity.this, checkeractivity.class); i.setflags(intent.flag_activity_new_task); i.putextra("generatedotp", sentotp); startactivity(i); finish(); toast.maketext(sendactivity.this, "enter phone number!!", toast.length_long).show(); } } });
upon clicking button, messaging app opens , backgrounded checkeractivity started. want when message app opens, send message, , click send button send message, checkeractivity gets started.
how can accomplish this? need set additional intent flags?
start sms intent results, on results can start activity.
Comments
Post a Comment