Answer the question
In order to leave comments, you need to log in
Can't figure out how action_send works in android?
Wrote this activity:
public class SendWelcomeActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
if ("*/*".equals(type)) {
try {
Person person = (Person) intent.getSerializableExtra(Intent.EXTRA_STREAM);
SerializationAndDeserialization.writeToFile(person.getName(), person, this);
saveName(person.getName());
} catch (Exception e) {
Toast.makeText(this, "Unknown format of file!", Toast.LENGTH_LONG).show();
}
}
}
finish();
}
private void saveName(String name) {
InformationAboutPersons inf = new InformationAboutPersons();
String[] names = inf.getNames(this);
if (names != null) {
for (int i = 0; i < names.length; i++) {
if (names[i].equals(name)) {
return;
}
}
inf.addNamePerson(name, this);
} else {
inf.addNamePerson(name, this);
}
}
}
<activity android:name=".Controller.SendWelcomeActivity">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
try {
String FILENAME = "filesLifeOrganizationRe" + mPerson.getName() + ".person";
File imageFile = getFileStreamPath(FILENAME);
Uri imageUri = Uri.fromFile(imageFile);
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("*/*");
emailIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
this.startActivityForResult(Intent.createChooser(emailIntent, "Send mail..."), 1);
} catch (Exception e) {
e.printStackTrace();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question