简体   繁体   中英

Android/ Java.io.IOException(313)

I am using the following code to send an e-mail from an Android2.2 app it is throwing this exception:

03-10 12:36:31.161: ERROR/SendTransaction(313): java.io.IOException: Cannot establish route to 0 for null

This just started when I switched to MyEclipse for Spring 8.6. Worked fine in Eclipse Galileo...

Any ideas?

Thanks Neomon

private void SendMail(String mySubject, String myContent){  

        final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
        //intent.addCategory(Intent.CATEGORY_DEFAULT);
        final String someEmailAddressString = "someaddr@myplace.com";
        final String someSubjectString = mySubject;
        final String someEmailContentString = myContent;
        try{
        //intent.setType("plain/text"); //Throws no e-mail present in emulator
        intent.setType("image/jpeg"); //This works for testing
        //intent.addCategory(Intent.CATEGORY_DEFAULT);
        //intent.getAction();
        intent.putExtra(Intent.EXTRA_EMAIL, new String[]{someEmailAddressString});      
        intent.putExtra(Intent.EXTRA_SUBJECT, someSubjectString);       
        intent.putExtra(Intent.EXTRA_TEXT, someEmailContentString);

        //startActivity(intent);  
        startActivity(Intent.createChooser(intent, "Send mail"));
       Toast.makeText(TimeCard.this, "Sending-"+ mySubject, Toast.LENGTH_LONG).show();

        }catch(Exception e){
            final String DEBUG_ERR = "SENDMAIL";
            Log.e(DEBUG_ERR, "Basic-" + e.getMessage().toString());
        }

    }

To fix in the emulator ; add :

-dns-server XXXX (some sound dns server you know of; may be 8.8.8.8) to command line, to fix in Eclipse rightClick

project > Run As > Run Configurations > target > additional Emulator command line options

and add them there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM