1

I want to send data from my android app to Office Mobile (particularly Word Document) android app. What value should I supply at the setType() method below, the current value does not bring Office Mobile among options. It just brings twitter, facebook, etc.

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(sendIntent);
Santiago Hernández
  • 5,438
  • 2
  • 26
  • 34
Samuel Thomas
  • 117
  • 1
  • 2
  • 10
  • Possible duplicate of [How can I setup an android intent for multiple types of files (pdf, office, images, text) and return a path?](http://stackoverflow.com/questions/27367272/how-can-i-setup-an-android-intent-for-multiple-types-of-files-pdf-office-imag) – Bishan Aug 26 '16 at 02:50
  • Possible duplicate of [Android: Opening a Word document using intents and FileProvider](https://stackoverflow.com/questions/54836448/android-opening-a-word-document-using-intents-and-fileprovider) – Shreshth Kharbanda Oct 30 '19 at 03:36

1 Answers1

-1

Try this:

public static void openFile(Context context, File url) throws IOException {
    // Create URI
    File file=url;
    Uri uri = Uri.fromFile(file);

    Intent intent = new Intent(Intent.ACTION_VIEW);

    if(url.toString().contains(".docx")) {
        // Text file
        intent.setDataAndType(uri, "text/plain");
}

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
        context.startActivity(intent);

Some other links in case this doesn't work: Android how to open a .doc extension file? https://developer.android.com/guide/components/intents-filters.html

Hope it works! Good Luck! Happy Coding!

Community
  • 1
  • 1
Shreshth Kharbanda
  • 1,777
  • 14
  • 24