Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. @Override
  2. public void onClick(View v)
  3. {
  4. String filePath = (String)v.getTag();
  5. File fileToView = new File(filePath);
  6. Intent viewIntent = new Intent(Intent.ACTION_VIEW);
  7. viewIntent.setData(Uri.fromFile(fileToView));
  8. final Intent chooserIntent = Intent.createChooser(viewIntent, "Choose an app to open this file:");
  9. startActivity(chooserIntent);
  10. }
  11.  
  12. <activity
  13. android:name="YOUR_PICKED_ACTIVITY"
  14. android:launchMode="singleTask"
  15. android:screenOrientation="portrait"
  16. android:theme="@style/AppTheme"
  17. android:windowSoftInputMode="adjustResize">
  18. <intent-filter>
  19. <action android:name="android.intent.action.SEND" />
  20. <category android:name="android.intent.category.DEFAULT" />
  21. <data android:mimeType="*/*" //THIS IS THE TYPE OF YOUR FILE */* for any file />
  22. </intent-filter>
  23. </activity>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement