title: Android read text file in Activity that filters opening text files
body: <p>I have Activity that "listening" to open text files, which means in manifest:</p>
  
  <pre><code>&lt;intent-filter&gt;
      &lt;action android:name="android.intent.action.VIEW" /&gt;
      &lt;category android:name="android.intent.category.DEFAULT" /&gt;
      &lt;data android:mimeType="text/*" /&gt;
  &lt;/intent-filter&gt;
  </code></pre>
  
  <p>So I navigate to file browser, find some text file and try to open it, and as expected this Activity exists on the list of available applications to complete the action. When the activity launches I know the Activity got the correct file name but it treats the file as empty (not printing to the log the content).</p>
  
  <p>Remarks: The file is not empty, other apps can read him, the file path not contains white spaces, no exceptions or crashes.</p>
  
  <p>What i'm doing wrong here? </p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_display);
      //Get intent, action and MIME type
      Intent intent = getIntent();
      String action = intent.getAction();
      String type = intent.getType();
      if (Intent.ACTION_VIEW.equals(action) &amp;&amp; type != null &amp;&amp; "text/plain".equals(type)) {
          handleViewText(intent);  //Handle text being sent
      }
  }
  
  private void handleViewText(Intent intent) {
      Uri uri = intent.getData();
      //uri.getPath().toString(): /storage/emulated/0/dir/subDir/fileName.txt
      BufferedReader br = null;
      try {
          String sCurrentLine;
          InputStream is = getContentResolver().openInputStream(uri);
          br = new BufferedReader(new InputStreamReader(is));
          //This is also not working: br = new BufferedReader(new FileReader(uri.getPath()));
          while ((sCurrentLine = br.readLine()) != null) {
              Log.e("TAG", sCurrentLine);  //never enters here
          }
      } catch (Exception e) {
          //nothing
      } finally {
          try {
              if (br != null) br.close();
          } catch (Exception e) {
              //nothing
          }
      }
  }  
  </code></pre>