我正在尝试直接通过DialogFragment
上的按钮发送文件,但意图不会打开并被跳过。有什么想法吗?
此代码位于onCreateView
DialogFragment
方法内
createWithEmail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//create file than move right into email
fileName = editFileName.getText().toString();
//create file
createFile();
//set up email
Intent i = new Intent(Intent.ACTION_SEND);
File file = new File(getActivity().getExternalCacheDir(), fileName);
i.setType("image/png");
i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
i.putExtra(Intent.EXTRA_TEXT, "From:" + user.getName() + "\n" + "\n" + "Company Name:" + user.getCompany() + "\n" + "\n" + "Date of meeting to present:");
try {
getActivity().startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(getActivity(), "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
//dismiss
getDialog().dismiss();
realm.close();
startActivity(new Intent(getActivity(), OldLocation.class));
}
});