Hi,
Although I have seen several threads and tutorials on this topic, I guess I still have some confusion on how an application can be chosen from a list of applications to display a file.
I have a Activity which has a list view in it. This list view is bound with file paths (so a file browser of sorts). When we click on a specific file type, I need a list of applications that can open that file.
So far this is what I have in the OnItemClick for the list item:
Intent myIntent = new Intent();
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
myIntent.setAction(Intent.ACTION_VIEW);
myIntent.addCategory("android.intent.category.DEFAULT");
myIntent.setData(Uri.fromFile(new File(filePath)));
When I run this on my phone, the error is:
No Activity found to handle Intent { act=android.intent.action.VIEW cat=[android.intent.category.DEFAULT] dat=file:///
When I do the same in a file browser application (downloaded from the marketplace), I get two options (QuickOffice and Word to Go), both of which I have installed on my phone.
Could someone guide me as to what else is needed here? Things I have tried besides the above:
Add the following entries to the manifest:
<intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" > <category android:name="android.intent.category.DEFAULT" > <data android:scheme="file" /> </intent-filter>Explicitly set the type:
myIntent.setDataAndType(Uri.fromFile(new File(filePath)),"*");
Neither of this works, any help is appreciated.
Thanks!