I faced this problem, and the only wraparound that worked with me is to check in the onActivityResults method if the data string contains the extensions we don't want such as jpg, jpeg, etc, i suggest you keep choosing the files you don't want and check its data string in the loggat, so i am using the following code
if(requestCode == BookDialog.ChooseFile){
if(data!=null) {
final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("application/pdf");
intent.addCategory(Intent.CATEGORY_OPENABLE);
String dataUri = data.getDataString();
if(dataUri!=null&&(dataUri.contains("jpg")||dataUri.contains("png")||dataUri.contains("jpeg")
||dataUri.contains("gif")||dataUri.contains("image")||dataUri.contains("video")||dataUri.contains("audio")
||dataUri.contains("mp3")||dataUri.contains("mp4"))){
Toast.makeText(getActivity(),"Please select only a text file\n (pdf or word)",Toast.LENGTH_LONG).show();
startActivityForResult(Intent.createChooser(intent,"ChooseFile"),BookDialog.ChooseFile);
}else if(dataUri.contains("apk")){
new AlertDialog.Builder(getActivity()).setTitle("My apology").setMessage("We may work on this issue in the near future, but can you" +
" choose this file from the directory it belongs to? :/").setPositiveButton("Apology accepted", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
startActivityForResult(intent,BookDialog.ChooseFile);
}
}).setNegativeButton("Not accepted", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Toast.makeText(getActivity(),"Sorry for this frustration :(",Toast.LENGTH_LONG).show();
getDialog().dismiss();
}
}).create().show();
}else {
Cursor c = getActivity().getContentResolver().query(data.getData(), null, null, null, null);
if (c != null) {
c.moveToFirst();
}
String filename = c.getString(c.getColumnIndex(OpenableColumns.DISPLAY_NAME));
fileLink.setText(filename);
}