Works on emulator but not on device

Posted by Klaus on Stack Overflow See other posts from Stack Overflow or by Klaus
Published on 2010-12-29T12:51:13Z Indexed on 2010/12/29 12:53 UTC
Read the original article Hit count: 168

Hello Community,

I have an inner handler class that calls the method sendMessage. sendMessige is outside the handler class, but inside the conatining Android java class.

On the emulator (AVD 2.2) it works fine, but on my Android 2.2 device the method sendMessage is not called at all.

Inner handler class:

private Handler handler2 = new Handler() {      
    public void handleMessage(Message msg) {

        if (GeoSetting.equals("s") && (inNumber.equals(definedNumber))) **SendService.this.sendMessage(definedNumber, DisplayLoc)**;
        if (GeoSetting.equals("a")) **SendService.this.sendMessage(inNumber, DisplayLoc)**;

        stopService(new Intent(getApplicationContext(), GeoService.class));               

   };

The method that should be called:

private void sendMessage(String sendNumber, String sendText){

    Toast.makeText(getApplicationContext(), "done!!!", Toast.LENGTH_LONG).show();

    SmsManager sms = SmsManager.getDefault();

    try {
        sms.sendTextMessage(sendNumber, null, sendText, null, null); 
        if (Message == true) {Toast.makeText(getApplicationContext(), "Sending SMS to "+sendNumber+": "+sendText, Toast.LENGTH_LONG).show();}
    } 

    catch (Exception exeption){
        Toast.makeText(getApplicationContext(), "Something is wrong, could not send SMS!", Toast.LENGTH_LONG).show();
    }



    Toast.makeText(getApplicationContext(), "method called!", Toast.LENGTH_LONG).show();
}

Does anybody have an idea why sendMessage is not called on the real device? Thank you for the help!

© Stack Overflow or respective owner

Related posts about android

Related posts about methods