I am trying to setup and email to be sent from within my jME android app. To send the email, I have created the following class:
[java]public class SendEmailActivity extends Activity {
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
Log.d(“MyDebug”, “About to create email activity…”);
super.onCreate(savedInstanceState);
Log.d(“MyDebug”, “Just created email activity.”);
// Get the file to send
Intent intent = getIntent();
String filePath = intent.getExtras().getString("filePath");
// Create an intent to send the email
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL, new String[]{"tomsrobots@gmail.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "Motion Capture Data");
i.putExtra(Intent.EXTRA_TEXT, "Here is the data from your latest motion capture");
// Grab file
File fileToSend = new File(filePath);
Uri fileUri = Uri.fromFile(fileToSend);
i.putExtra(Intent.EXTRA_STREAM, fileUri);
Log.d("MyDebug", "Trying to send email...");
try {
startActivity(Intent.createChooser(i, "Send mail..."));
finish();
} catch (android.content.ActivityNotFoundException ex) {
Log.d("MyDebug", "There are no email clients installed");
}
}
}[/java]
This code works great when I call it from onCreate inside of MainActivity. However, I want to prompt this activity from within the jME update loop. I have created an AppState on the Android side that gives me access to the jME update loop and when I start this state, I be sure to pass the MainActivity’s context to it. Inside I have this:
[java] @Override
public void update(float tpf) {
super.update(tpf);
rootNode.updateLogicalState(tpf);
rootNode.updateGeometricState();
if (firstLoop) {
firstLoop = false;
// This starts a new activity and sends the email with the text file
Intent emailIntent = new Intent(context, SendEmailActivity.class);
String filePath = Environment.getExternalStorageDirectory().toString() + "/MoCap/TomsFile.txt";
emailIntent.putExtra("filePath", filePath);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(emailIntent);
}
}[/java]
This will successfully launch the email client and I am able to send the email as I would expect. However, when I am finished with the email and I should return back to the jME loop, I get a OpenGL 1285 error. Reading about this error, it looks to be a memory out of bounds error and can happen when large textures are loaded. Why is this error being reported? Also, I have no doubt that I may be trying to do this a crazy way. From what I have been reading, AndroidHarness starts up the jME application in a GLSurfaceView, is that correct? If this is the case, then jME is running in a glThread and I no longer have access to MainActivity? Or is there a way to access MainActivity so that I can start an activity without starting it from the context?
P-Worm