1
I’m new as an Android programmer, I’ve been researching various research sources on how to text my email, I’ve taken an example of a book on the internet, however while running it did not generate any error and only reported a message on screen that could not understand due to my lack of experience.
that was the messages in Logcat
11-26 18:09:43.721: I/Choreographer(790): Skipped 31 frames! The application may be doing too much work on its main thread.
11-26 18:09:43.971: D/gralloc_goldfish(790): Emulator without GPU emulation detected.
11-26 18:10:22.246: D/dalvikvm(790): GC_FOR_ALLOC freed 87K, 9% free 2556K/2788K, paused 27ms, total 30ms
11-26 18:10:22.476: I/Choreographer(790): Skipped 86 frames! The application may be doing too much work on its main thread.
that was the screen
this is my project
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/btnSendEmail"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="Send Email" />
</LinearLayout>
package br.com.google.sms2;
import com.example.sms2.R;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
public class EmailsActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void onClick(View v) {
String[] to = { "[email protected]" };
String[] cc = { "[email protected]" };
sendEmail(to, cc, "hello", "helo meu amigo");
}
private void sendEmail(String[] emailAddresses, String[] carbonCopies,
String subject, String message) {
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setData(Uri.parse("mailto:"));
String[] to = emailAddresses;
String[] cc = carbonCopies;
emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
emailIntent.putExtra(Intent.EXTRA_CC, cc);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_TEXT, message);
emailIntent.setType("message/rfc822");
startActivity(Intent.createChooser(emailIntent, "Email"));
}
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sms2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity android:name="br.com.google.sms2.EmailsActivity" android:label="@string/app_name">
<intent-filter >
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
You are using the emulator. Check if the emulator has an email application. You also have to set up an email account.
– ramaral
Give me a reference to configure the emulator to send email, because I know where to start, even for me search is difficult because I do not know how to search too, and show me also email configuration, would be Telnet? my telnet is installed and activated and my emulator already receives message by telnet.
– wladyband
Behold this
– ramaral