Paste text in Edit Text from an SMS automatically in Huawei










0















I have a class that extends BroadcastReceiver and reads code from an SMS and pastes it automatically in an EditText , this works perfectly on Samsung and Nexus Emulator, but now it's not working on Huawei , it does copy the text.. but then user needs to paste it manually..



This is my code:



public class SimpleSmsReciever extends BroadcastReceiver 


@Override
public void onReceive(Context context, Intent intent)
Bundle pudsBundle = intent.getExtras();
Object pdus = (Object) Objects.requireNonNull(pudsBundle).get("pdus");
String format = pudsBundle.getString("format");
SmsMessage messages =SmsMessage.createFromPdu((byte) Objects.requireNonNull(pdus)[0],format);

// check if sender is specificSender
if(messages.getOriginatingAddress().equalsIgnoreCase("specificSender"))
// get only the numbers from the sms
String number = messages.getMessageBody().replaceAll("[^0-9]", "");

// place the code in the edit text
if(VerifyActivity.isVerifyRunning)
VerifyActivity.et_code.setText(number);
else if(BaseActivity.isChangeNumberOn)

EditText et = BaseActivity.changeNumber.findViewById(R.id.et_code);
et.setText(number);








Do you have any idea what might cause this?




is it related to Huawei devices or is there something I should add to my
code?




Thank You.










share|improve this question
























  • add your code please

    – Milad Bahmanabadi
    Nov 14 '18 at 7:33











  • ok I added it..

    – Outlandish
    Nov 14 '18 at 8:21















0















I have a class that extends BroadcastReceiver and reads code from an SMS and pastes it automatically in an EditText , this works perfectly on Samsung and Nexus Emulator, but now it's not working on Huawei , it does copy the text.. but then user needs to paste it manually..



This is my code:



public class SimpleSmsReciever extends BroadcastReceiver 


@Override
public void onReceive(Context context, Intent intent)
Bundle pudsBundle = intent.getExtras();
Object pdus = (Object) Objects.requireNonNull(pudsBundle).get("pdus");
String format = pudsBundle.getString("format");
SmsMessage messages =SmsMessage.createFromPdu((byte) Objects.requireNonNull(pdus)[0],format);

// check if sender is specificSender
if(messages.getOriginatingAddress().equalsIgnoreCase("specificSender"))
// get only the numbers from the sms
String number = messages.getMessageBody().replaceAll("[^0-9]", "");

// place the code in the edit text
if(VerifyActivity.isVerifyRunning)
VerifyActivity.et_code.setText(number);
else if(BaseActivity.isChangeNumberOn)

EditText et = BaseActivity.changeNumber.findViewById(R.id.et_code);
et.setText(number);








Do you have any idea what might cause this?




is it related to Huawei devices or is there something I should add to my
code?




Thank You.










share|improve this question
























  • add your code please

    – Milad Bahmanabadi
    Nov 14 '18 at 7:33











  • ok I added it..

    – Outlandish
    Nov 14 '18 at 8:21













0












0








0








I have a class that extends BroadcastReceiver and reads code from an SMS and pastes it automatically in an EditText , this works perfectly on Samsung and Nexus Emulator, but now it's not working on Huawei , it does copy the text.. but then user needs to paste it manually..



This is my code:



public class SimpleSmsReciever extends BroadcastReceiver 


@Override
public void onReceive(Context context, Intent intent)
Bundle pudsBundle = intent.getExtras();
Object pdus = (Object) Objects.requireNonNull(pudsBundle).get("pdus");
String format = pudsBundle.getString("format");
SmsMessage messages =SmsMessage.createFromPdu((byte) Objects.requireNonNull(pdus)[0],format);

// check if sender is specificSender
if(messages.getOriginatingAddress().equalsIgnoreCase("specificSender"))
// get only the numbers from the sms
String number = messages.getMessageBody().replaceAll("[^0-9]", "");

// place the code in the edit text
if(VerifyActivity.isVerifyRunning)
VerifyActivity.et_code.setText(number);
else if(BaseActivity.isChangeNumberOn)

EditText et = BaseActivity.changeNumber.findViewById(R.id.et_code);
et.setText(number);








Do you have any idea what might cause this?




is it related to Huawei devices or is there something I should add to my
code?




Thank You.










share|improve this question
















I have a class that extends BroadcastReceiver and reads code from an SMS and pastes it automatically in an EditText , this works perfectly on Samsung and Nexus Emulator, but now it's not working on Huawei , it does copy the text.. but then user needs to paste it manually..



This is my code:



public class SimpleSmsReciever extends BroadcastReceiver 


@Override
public void onReceive(Context context, Intent intent)
Bundle pudsBundle = intent.getExtras();
Object pdus = (Object) Objects.requireNonNull(pudsBundle).get("pdus");
String format = pudsBundle.getString("format");
SmsMessage messages =SmsMessage.createFromPdu((byte) Objects.requireNonNull(pdus)[0],format);

// check if sender is specificSender
if(messages.getOriginatingAddress().equalsIgnoreCase("specificSender"))
// get only the numbers from the sms
String number = messages.getMessageBody().replaceAll("[^0-9]", "");

// place the code in the edit text
if(VerifyActivity.isVerifyRunning)
VerifyActivity.et_code.setText(number);
else if(BaseActivity.isChangeNumberOn)

EditText et = BaseActivity.changeNumber.findViewById(R.id.et_code);
et.setText(number);








Do you have any idea what might cause this?




is it related to Huawei devices or is there something I should add to my
code?




Thank You.







java android broadcastreceiver huawei






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 8:20







Outlandish

















asked Nov 14 '18 at 7:19









OutlandishOutlandish

309




309












  • add your code please

    – Milad Bahmanabadi
    Nov 14 '18 at 7:33











  • ok I added it..

    – Outlandish
    Nov 14 '18 at 8:21

















  • add your code please

    – Milad Bahmanabadi
    Nov 14 '18 at 7:33











  • ok I added it..

    – Outlandish
    Nov 14 '18 at 8:21
















add your code please

– Milad Bahmanabadi
Nov 14 '18 at 7:33





add your code please

– Milad Bahmanabadi
Nov 14 '18 at 7:33













ok I added it..

– Outlandish
Nov 14 '18 at 8:21





ok I added it..

– Outlandish
Nov 14 '18 at 8:21












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53294943%2fpaste-text-in-edit-text-from-an-sms-automatically-in-huawei%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53294943%2fpaste-text-in-edit-text-from-an-sms-automatically-in-huawei%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3

Museum of Modern and Contemporary Art of Trento and Rovereto