
So in ImportDataActivity we need to import the data stored in the attachment, in my case this was JSON. So the solution was simply to create a new “ImportDataActivity” that handled the data import from the attachment, and then launched the home Activity with the Intent.FLAG_ACTIVITY_CLEAR_TOP flag added. Which prevents multiple instances of it being launched, this is important when users can launch the app from either the launcher icon or in this case via attachment (I didn’t want to have multiple instances of my home Activity running as that would confuse the user). I realised this was because my Activity’s tag had the launch mode set to: android:launchMode="singleTask" I initially put these IntentFilters on the “home” Activity of my app, however I soon started encountering security exceptions in LogCat detailing how my Activity didn’t have access to the data from the other process (Gmail).
How to view file types in android android#
We have iOS users and Android users sharing timers via email, and with iOS the mime type is set, with Android, at least in my tests on Android 4.2, the mime-type reverts to application/octet-stream for attachments sent from within the app. The reason for this is because we can’t guarantee the attachment’s mime-type has been set correctly. Now something to note here, I’ve specified a filter for both “application/mytype” mimetype and also the more generic “application/octet-stream” mime type. The first step is to add nodes to the application node of the AndroidManifest.xml. Create IntentFilters in AndroidManifest.xml #

How to view file types in android trial#
After some trial and error, I came up with this method. The most common was that your app would appear in the chooser dialog whenever the user clicked on an email notification, for any email – not just those with your attachment.

There are many pitfalls to doing this, and the Stack Overflow answers I saw given for the question had various side-effects or problems. Specifically I wanted this to happen when the user opened an email attachment, as data is shared between users via email attachment for this app.

I’ve recently finished work on an app that registers itself as a handler for a given file extension, let’s call it “.mytype”, so if the user attempts to open a file named “file1.mytype” our app would launch and receive an Intent containing the information on the file’s location and its data can be imported.
