There is a DialogFragment (SettingsBackImageDialog) opens by click on button in Fragment (TrainerSettings) in MainActivity. In SettingsBackImageDialog are some buttons, one of them is for take picture and set it for Imageview (trainersettingsmainicon) in Fragment.
I open SettingsBackImageDialog in TrainerSettings by:
public void onViewCreated (View view, Bundle savedInstanceState) {
view.findViewById(R.id.trainersettingsbackgroundbtn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showEditbackImageDialog();
}
});
}
private void showEditbackImageDialog() {
android.support.v4.app.FragmentManager fm = getActivity().getSupportFragmentManager();
SettingsBackImageDialog settingsBackImageDialog = SettingsBackImageDialog.newInstance("Wybierz pierwszy kolor");
settingsBackImageDialog.show(fm, "SettingsBackImageDialog");
}
My code from SettingsBackImageDialog is:
public class SettingsBackImageDialog extends DialogFragment {
int REQUESTCODE=1;
public SettingsBackImageDialog() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.settingsbackgroundimgdialog, container);
}
@Override
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
view.findViewById(R.id.takephotobtn).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, REQUESTCODE);
}
});
String title = getArguments().getString("txt", "txt");
getDialog().setTitle(title);
getDialog().getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Toast.makeText(getActivity(), "before", Toast.LENGTH_LONG).show();
if(requestCode==REQUESTCODE & resultCode== Activity.RESULT_OK){
Bundle bundle = new Bundle();
bundle = data.getExtras();
Bitmap bitmap = (Bitmap)bundle.get("data");
ImageView img = (ImageView) getActivity().findViewById(R.id.trainersettingsmainicon);
img.setImageBitmap(bitmap);
Toast.makeText(getActivity(), "in", Toast.LENGTH_LONG).show();
}
}
}
In MainActivity:
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.MainContainer);
fragment.onActivityResult(requestCode, resultCode, data);
Toast.makeText(getApplicationContext(), "im here", LENGTH_SHORT).show();
}
Application opens camera, I can take piture and "accept" it but nothing else happend. Probably application never uses onActivityResult method (I try to write some message in this method but nothing happend).
In AndroidMonitor:
05-09 02:43:50.299 9709-10068/com.hgyghyfghyu.apkana40 W/GooglePlayServicesUtil: Google Play services out of date. Requires 8115000 but found 5089070
05-09 02:43:50.339 9709-9709/com.hgyghyfghyu.apkana40 W/EGL_emulation: eglSurfaceAttrib not implemented
I use nox app to emulate android phone.
What should I do to solve my problem?