Here is a simplified version of how I handle csv files and text files in my app. I hope this help:
@Override
public void onNewIntent(final Intent intent)
{
super.onNewIntent(intent);
String type = intent.getType();
String action = intent.getAction();
if ("text/csv".equals(type) || "text/comma-separated-values".equals(type))
{
// Handle CSV file being sent
handleSendCSV(intent);
}
else if("text/plain".equals(type) && Intent.ACTION_SEND.equals(action))
{
// Handle plaintext sent
handlePlainText(intent);
}
else
{
//Alert of some error
doAlertDialog("Error.", "Invalid file type.");
}
}
Edit-
Added:
String action = intent.getAction();
So the code would be complete.