Example usage for android.content Intent ACTION_OPEN_DOCUMENT

List of usage examples for android.content Intent ACTION_OPEN_DOCUMENT

Introduction

In this page you can find the example usage for android.content Intent ACTION_OPEN_DOCUMENT.

Prototype

String ACTION_OPEN_DOCUMENT

To view the source code for android.content Intent ACTION_OPEN_DOCUMENT.

Click Source Link

Document

Activity Action: Allow the user to select and return one or more existing documents.

Usage

From source file:Main.java

public static Intent startGetPicPhotoAlbum() {
    Intent intent = null;/*ww  w. ja  v  a 2 s  . com*/
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
    } else {
        intent = new Intent(Intent.ACTION_GET_CONTENT);
    }
    intent.setType("image/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    return intent;
}

From source file:com.commonsware.android.tte.DocumentStorageService.java

public static void loadDocument(Context ctxt, Uri document) {
    Intent i = new Intent(ctxt, DocumentStorageService.class).setAction(Intent.ACTION_OPEN_DOCUMENT)
            .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION).setData(document);

    ctxt.startService(i);//w w w.  ja  v  a2 s . c o  m
}

From source file:com.waz.zclient.pages.main.conversation.AssetIntentsManager.java

@TargetApi(19)
private static String openDocumentAction() {
    return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) ? Intent.ACTION_OPEN_DOCUMENT
            : Intent.ACTION_GET_CONTENT;
}

From source file:org.jak_linux.dns66.ItemActivity.java

public void performFileSearch() {
    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);

    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType("*/*");
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);

    startActivityForResult(intent, READ_REQUEST_CODE);
}

From source file:com.commonsware.android.tte.DocumentStorageService.java

@Override
protected void onHandleIntent(Intent intent) {
    if (Intent.ACTION_OPEN_DOCUMENT.equals(intent.getAction())) {
        load(intent.getData());/*  w  ww .  j  a va  2 s. c  o m*/
    } else if (Intent.ACTION_EDIT.equals(intent.getAction())) {
        save(intent.getData(), intent.getStringExtra(Intent.EXTRA_TEXT),
                intent.getBooleanExtra(EXTRA_CLOSING, false));
    }
}

From source file:com.runzii.paintmooc.ui.fragments.StorageClientFragment.java

/**
 * Fires an intent to spin up the "file chooser" UI and select an image.
 *///from w w w . j a v a 2s .c o m
public void performFileSearch() {

    // ACTION_OPEN_DOCUMENT is the intent to choose a file via the system's file browser.
    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);

    // Filter to only show results that can be "opened", such as a file (as opposed to a list
    // of contacts or timezones)
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    // Filter to show only images, using the image MIME data type.
    // If one wanted to search for ogg vorbis files, the type would be "audio/ogg".
    // To search for all documents available via installed storage providers, it would be
    // "*/*".
    intent.setType("image/*");

    startActivityForResult(intent, READ_REQUEST_CODE);
}

From source file:com.example.android.storageclient.StorageClientFragment.java

/**
 * Fires an intent to spin up the "file chooser" UI and select an image.
 *///ww  w.java2 s .c o  m
public void performFileSearch() {

    // BEGIN_INCLUDE (use_open_document_intent)
    // ACTION_OPEN_DOCUMENT is the intent to choose a file via the system's file browser.
    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);

    // Filter to only show results that can be "opened", such as a file (as opposed to a list
    // of contacts or timezones)
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    // Filter to show only images, using the image MIME data type.
    // If one wanted to search for ogg vorbis files, the type would be "audio/ogg".
    // To search for all documents available via installed storage providers, it would be
    // "*/*".
    intent.setType("image/*");

    startActivityForResult(intent, READ_REQUEST_CODE);
    // END_INCLUDE (use_open_document_intent)
}

From source file:org.strongswan.android.ui.activity.TrustedCertificateImportActivity.java

@TargetApi(Build.VERSION_CODES.KITKAT)
@Override//  w w  w  .  j a  va 2 s.c  om
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) { /* do nothing when we are restoring */
        return;
    }

    Intent intent = getIntent();
    String action = intent.getAction();
    if (Intent.ACTION_VIEW.equals(action)) {
        importCertificate(intent.getData());
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Intent openIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
        openIntent.setType("*/*");
        openIntent.putExtra(Intent.EXTRA_MIME_TYPES, ACCEPTED_MIME_TYPES);
        startActivityForResult(openIntent, OPEN_DOCUMENT);
    }
}

From source file:com.nextome.geojsonviewer.MainActivity.java

public void openFilePicker(View v) {
    Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType("application/octet-stream");
    startActivityForResult(intent, READ_REQUEST_CODE);
}

From source file:com.HumanDecisionSupportSystemsLaboratory.DD_P2P.SendPK.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.dialog_send_pk, container);

    Intent i = getActivity().getIntent();
    Bundle b = i.getExtras();/*w ww. j a va  2s  .  c  o m*/
    safe_lid = b.getString(Safe.P_SAFE_LID);

    peer = D_Peer.getPeerByLID(safe_lid, true, false);
    if (peer == null) {
        Toast.makeText(getActivity(), "No peer. Reload!", Toast.LENGTH_SHORT).show();
        //finish();
    }

    exportByPhoto = (Button) view.findViewById(R.id.dialog_send_pk_export_by_picture);
    sendVia = (Button) view.findViewById(R.id.dialog_send_pk_send_via);

    getDialog().setTitle("Export public key");

    exportByPhoto.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            if (Build.VERSION.SDK_INT < 19) {
                Intent intent = new Intent();
                intent.setType("image/*");
                intent.setAction(Intent.ACTION_GET_CONTENT);
                startActivityForResult(intent, SELECT_PHOTO);

                FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
                ft.detach(SendPK.this);
                ft.commit();
            } else {
                Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
                intent.setType("image/*");
                startActivityForResult(intent, SELECT_PHOTO_KITKAT);
                FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
                ft.detach(SendPK.this);
                ft.commit();
            }
        }
    });

    sendVia.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (peer == null) {
                Toast.makeText(getActivity(), "No peer. Reload!", Toast.LENGTH_SHORT).show();
                return;
                //finish();
            }
            //DD_Address adr = new DD_Address(peer);

            String msgBody = DD.getExportTextObjectBody(peer); //adr.getBytes());

            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("text/plain");
            i.putExtra(Intent.EXTRA_TEXT, msgBody); //Safe.SAFE_TEXT_MY_BODY_SEP + Util.stringSignatureFromByte(adr.getBytes()));
            /*
                        String slogan = peer.getSlogan_MyOrDefault();
                        if (slogan == null) slogan = "";
                        else slogan = "\""+slogan+"\"";
                        i.putExtra(Intent.EXTRA_SUBJECT, "DDP2P: Safe Address of \""+peer.getName()+"\",  "+slogan+Safe.SAFE_TEXT_MY_HEADER_SEP);
            */
            i.putExtra(Intent.EXTRA_SUBJECT, DD.getExportTextObjectTitle(peer));
            i = Intent.createChooser(i, "send Public key");
            startActivity(i);
            FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
            ft.detach(SendPK.this);
            ft.commit();
        }
    });

    return view;
}