I am trying to show a dialog when picture taken so I setup a broadcast receiver on picture taken by default camera app. I read that I need to call an activity to achieve that. I setup the activity so the theme in the manifest is like transparent
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen
here is my code
public class CameraEventReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Cursor cursor = context.getContentResolver().query(intent.getData(), null,null, null, null);
cursor.moveToFirst();
String image_path = cursor.getString(cursor.getColumnIndex("_data"));
Toast.makeText(context, "New Photo is Saved as : -" + image_path, Toast.LENGTH_SHORT).show();
Intent i = new Intent(context, DialogActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
The problem is that my main app activity is being displayed behind the Dialog activity so that the main activity is shown. I just want the dialog activity to be displayed on top of the picture. Is there a way to fix that?
Thank you
EDIT: As requested, my manifest:
<application
android:allowBackup="true"
android:name="MyApplication"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.xx.xx.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".DialogAcitivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
android:label="@string/app_name">
<intent-filter>
<action android:name="com.xx.xx.DIALOGACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver
android:name=".CameraEventReceiver"
android:enabled="true" >
<intent-filter>
<action android:name="com.android.camera.NEW_PICTURE" />
<action android:name="android.hardware.action.NEW_PICTURE" />
<data android:mimeType="image/*" />
</intent-filter>
</receiver>
</application>
My code for button, basically ask the user for a value:
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Intent intent = getIntent();
promptUser();
}
private void promptUser() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
final EditText input = new EditText(this);
builder.setMessage(R.string.msg)
.setCancelable(false)
.setView(input)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString();
storeValue(value);
dialog.dismiss();
}).setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}