I have a problem with the Intent.createChooser PLEASE HELP

0

I have a question because I do not get the address of files that are images, videos, music but of text documents like word or .txt

public class minube_main extends Fragment {

final int ACTIVITY_CHOOSE_FILE = 1;
FloatingActionButton FBMN;
GridView gridView;

public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView=inflater.inflate(R.layout.minube_main,container,false);

    ArrayList<String> arrayList=new ArrayList<>();
    arrayList.add("1");
    arrayList.add("2");
    arrayList.add("3");
    arrayList.add("4");
    arrayList.add("5");
    arrayList.add("6");
    arrayList.add("7");
    arrayList.add("8");
    arrayList.add("9");
    arrayList.add("10");
    arrayList.add("11");
    arrayList.add("12");
    arrayList.add("13");
    arrayList.add("14");
    arrayList.add("15");

    gridView= (GridView) rootView.findViewById(R.id.ListaMN);
    gridView.setAdapter(new Adaptador_Archivo(getContext(),arrayList));



    FBMN=(FloatingActionButton) rootView.findViewById(R.id.FBMN);
    FBMN.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent chooseFile,intent;
            chooseFile=new Intent(Intent.ACTION_GET_CONTENT);
            chooseFile.setType("*/*");
            intent=Intent.createChooser(chooseFile,"Elige un archivo");
            startActivityForResult(intent,ACTIVITY_CHOOSE_FILE);
        }
    });

    return rootView;
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode){
        case ACTIVITY_CHOOSE_FILE:{
            try{
            Uri uri=data.getData();
            String filePath=uri.getPath();
            Etiqueta(getView(),filePath);}
            catch (Exception ignored){

            }
        }
    }
    //super.onActivityResult(requestCode, resultCode, data);
}

public void Etiqueta(View v, final String dir){

    AlertDialog.Builder builder= new AlertDialog.Builder(getContext());
    builder.setTitle("Subir Archivo");
    builder.setMessage("Etiqueta");

    final EditText input = new EditText(getContext());
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT);
    input.setLayoutParams(lp);
    builder.setView(input);

    builder.setPositiveButton("Siguente", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
                Dialogo_Final(input.getText().toString(),dir);
                //Toast.makeText(getContext(),dir+" fecha:"+fecha+" etiqueta:"+input.getText().toString(),Toast.LENGTH_LONG).show();
        }
    });
    builder.setNegativeButton("Cancelar",null);
    Dialog dialog=builder.create();
    dialog.show();
}

public void Dialogo_Final(String et,String ar){

    SimpleDateFormat simpledateformat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
    Calendar calendar=Calendar.getInstance();
    String fecha=simpledateformat.format(calendar.getTime()).toString();

    AlertDialog.Builder builder= new AlertDialog.Builder(getContext());
    builder.setTitle("Confirmación");
    builder.setMessage("¿Esta seguro de subir este archivo?");
    final TextView E,F,A;
    E=new TextView(getContext());
    F=new TextView(getContext());
    A=new TextView(getContext());

    LinearLayout contenedor = new LinearLayout(getContext());
    contenedor.setLayoutParams(new LinearLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT));
    contenedor.setOrientation(LinearLayout.VERTICAL);
    contenedor.setGravity(Gravity.CENTER);

    E.setText("Etiqueta: "+et);
    A.setText("Archivo: "+ar);
    F.setText("Fecha: "+fecha);

    contenedor.addView(E);
    contenedor.addView(A);
    contenedor.addView(F);

    builder.setView(contenedor);

    builder.setPositiveButton("Subir", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {

        }
    });

    builder.setNegativeButton("Cancelar",null);
    Dialog dialog=builder.create();
    dialog.show();
}

}

When I choose a word, this is what I want.

but when I choose an image, music or video, this comes out in this image I chose the Excel.jpg

    
asked by emilio paredes 19.02.2018 в 07:52
source

0 answers