Created
July 18, 2014 19:42
-
-
Save illuzor/1fcc08159e4cb724bbf2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.illuzor.communicationextension.functions; | |
import android.content.Intent; | |
import android.net.Uri; | |
import java.util.ArrayList; | |
import com.adobe.fre.*; | |
public class SendEmailFuntion implements FREFunction { | |
@Override | |
public FREObject call(FREContext context, FREObject[] args) { | |
try { | |
String addresses = args[0].getAsString(); | |
String subject = args[1].getAsString(); | |
String message = args[2].getAsString(); | |
String filesPaths = args[3].getAsString(); | |
String[] addressesArray = addresses.split(","); | |
Intent emailIntent = new Intent(Intent.ACTION_SEND); | |
emailIntent.setType("message/rfc822"); | |
emailIntent.putExtra(Intent.EXTRA_EMAIL, addressesArray); | |
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); | |
emailIntent.putExtra(Intent.EXTRA_TEXT, message); | |
if(filesPaths != ""){ | |
String[] filesPathsArray = filesPaths.split(","); | |
ArrayList<Uri> uris = new ArrayList<Uri>(); | |
for (String filePath:filesPathsArray) { | |
Uri uri = Uri.parse("file://" + filePath); | |
uris.add(uri); | |
} | |
emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); | |
} | |
context.getActivity().startActivity(emailIntent); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment