Monday, 2 September 2013

Alert Dialog comes before another Intent activity finished

Alert Dialog comes before another Intent activity finished

In the following code spinet , I want that dialog comes only after
activity (Intent) i finished its work. I searched a lot but couldn't
figure out how to do this. :( Currently, dialog popped in between when
Intent I is doing work .
Do anyone know how to allow dialog to wait until Intent i finished its work
Thanks
Intent i = new Intent(MainActivity.this,
KeyFrame.class);
i.putExtra("keyFrame", filename1+"#"+duration);
//Log.e("Mobicom: Video Name" +
MainActivity.videoDir + video_filename,
MainActivity.videoDir + video_filename);
startActivity(i);
MainActivity.this.showDialog(MainActivity.GENRE_PREFERENCE_OPTION);
Here is the full code.
@Override
public Dialog onCreateDialog(int id) {
switch (id) {
case VIDEO_OPTION_DIALOG:
Builder optionDialog = new AlertDialog.Builder(this);
optionDialog.setTitle("Options");
optionDialog.setItems(
new String[] { "Option1", "Option2", "Delete", "Cancel"},
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int
which) {
String video_filename =
MainActivity.mSelectedVideoFilename;
String filename1 = MainActivity.videoDir +
video_filename;
switch (which) {
case OPTION_PREVIEW_ID:
// preview
startActivity(new
Intent().setAction(android.content.Intent.ACTION_VIEW).setDataAndType(Uri.fromFile(new
File(MainActivity.videoDir +
video_filename)), "video/*"));
break;
case OPTION_PREVIEW_WITH_RECOM_ID:
Intent i = new Intent(MainActivity.this,
KeyFrame.class);
i.putExtra("keyFrame",
filename1+"#"+duration);
//Log.e("Mobicom: Video Name" +
MainActivity.videoDir + video_filename,
MainActivity.videoDir + video_filename);
startActivity(i);
MainActivity.this.showDialog(MainActivity.GENRE_PREFERENCE_OPTION);
//finish();
break;
}

No comments:

Post a Comment