Sharing Text File using ACTION_SEND

后端 未结 1 1577
孤独总比滥情好
孤独总比滥情好 2021-01-05 03:54

We can open share dialog using ACTION_SEND to share text

     Intent sendIntent = new Intent();
                sendIntent.setAction(Intent.A         


        
相关标签:
1条回答
  • 2021-01-05 04:30

    Use the following line.

    Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); 
        emailIntent.setType("*/*");
        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] {"me@gmail.com"}); 
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, 
        "Test Subject"); 
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, 
        "go on read the emails");     
        emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromfile(new File(yourtextfilepath));
        startActivity(Intent.createChooser(emailIntent, "Send mail..."));
    

    Make sure that your text file path should be from external memory card. Action send wont accept the files from internal memory.

    Hope this will help you.

    0 讨论(0)
提交回复
热议问题