Algorithm:
1.) Create a new project by File-> New -> Android Project name it ActionSendFilter.
2.) You will see some default code into your main.xml, strings.xml and android manifest file.
3.) Write following into main.xml file:
2.) You will see some default code into your main.xml, strings.xml and android manifest file.
3.) Write following into main.xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This application shows how you can filter ACTION_SEND list to show only email allications.\n\n" />
<Button android:text="Share Via Email" android:id="@+id/Button"
android:layout_height="wrap_content"android:layout_width="wrap_content"></Button>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This application shows how you can filter ACTION_SEND list to show only email allications.\n\n" />
<Button android:text="Share Via Email" android:id="@+id/Button"
android:layout_height="wrap_content"android:layout_width="wrap_content"></Button>
</LinearLayout>
4.) Your launcher activity ActionSendFilterActivity will have one default functions OnCreate().
5.) Your device or simulator must have at least one email application such as gmail, ymail or default email configured to run this application.
Steps:
1.) Create a project named ActionSendFilter and set the information as stated in the image.
Build Target: Android 2.1
Application Name: ActionSendFilter
Package Name: com.example. actionsendfilter
Activity Name: ActionSendFilterActivity
Min SDK Version: 7
Application Name: ActionSendFilter
Package Name: com.example. actionsendfilter
Activity Name: ActionSendFilterActivity
Min SDK Version: 7
package com.example.actionsendfilter;
import java.io.File;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ActionSendFilterActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button cancelRecordButton = (Button) findViewById(R.id.Button);
cancelRecordButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent emailIntent = newIntent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_TITLE,"Send via");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"See the route I found on GeoTracker App");
String imagePath;
File f = newFile(Environment.getExternalStorageDirectory()+"/abc.txt");
imagePath = f.getPath();
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+imagePath));
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is a Demo email to show how to filter ACTION_SEND for emails only");
emailIntent.setType("vnd.android.cursor.dir/email");
startActivity(emailIntent);
}
});
}
}
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button cancelRecordButton = (Button) findViewById(R.id.Button);
cancelRecordButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent emailIntent = newIntent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_TITLE,"Send via");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"See the route I found on GeoTracker App");
String imagePath;
File f = newFile(Environment.getExternalStorageDirectory()+"/abc.txt");
imagePath = f.getPath();
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+imagePath));
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is a Demo email to show how to filter ACTION_SEND for emails only");
emailIntent.setType("vnd.android.cursor.dir/email");
startActivity(emailIntent);
}
});
}
}
3.) Compile and build the project.
4.) Run on simulator for the output which must have email application configured.
4.) Run on simulator for the output which must have email application configured.
Output
More details about this article click following link. http://www.edumobile.org/android/
0 comments
Thanks for your comment