I have searched and found a lot of different answers for this question, but nothing quite settles it for me. Total android n00b, and I ask for your patience in advance.
I'm having trouble dealing with a FileChooser problem with Android KitKat. As per [here][1], and according to [Steve N][2] i get the impression that this file chooser problem is caused by my android version (4.4.2)
Given that filechooser isn't working, I want to implement a basic dialog. I'm going to check the android version number for the device, and then display a message, citing the current lack of support, if the version number comes back with a 4.4 in front.
At present, i'm just using toast
public boolean checkVersionSupport(){
if (Build.VERSION.RELEASE.equals("4.4.2") {
Toast toast = Toast.makeText(context, androidOS, duration);
toast.show();
}
}
Instead of toast, I'd like a simple, one button dialog box to open, with an OK button, which I will use to redirect the user out of the native app and off to chrome, where the whole file chooser thing seems to be working.
Couple of things that I have found difficult after reading through the android developer materials.
Do I need a layout XML file for the dialog box?
Where do I put the class file for the MyAlertDialogFragment class I am creating? Can it be anywhere in the java folder or does it have to be in a sub folder java/com.myproject... And what impact does that have for importing the class into my java activity file?
Can someone please explain where FragmentAlertDialog comes from in the Android Developer Materials.
public static class MyAlertDialogFragment extends DialogFragment { public static MyAlertDialogFragment newInstance(int title) { MyAlertDialogFragment frag = new MyAlertDialogFragment(); Bundle args = new Bundle(); args.putInt("title", title); frag.setArguments(args); return frag; } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { int title = getArguments().getInt("title"); return new AlertDialog.Builder(getActivity()) .setIcon(R.drawable.alert_dialog_icon) .setTitle(title) .setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { ((**FragmentAlertDialog**)getActivity()).doPositiveClick(); } } ) .setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { ((**FragmentAlertDialog**)getActivity()).doNegativeClick(); } } ) .create(); } }
What's best practice for icons? I see a debate going on about this, but for the simple purpose of having an icon at the top of a dialog, for one single basic usage, what would be the quickest way of getting it done? I'm just copying files into the res folder and referencing them... 48dp? This might be a whole different question.