I want to open a PPT-file with my app. How can I check if there is an app that can display these files installed on the device and how can I launch it?

有帮助吗?

解决方案

Try something like this. Havent tried but might work

final Uri uri = Uri.fromFile(file); 
final Intent intent = new Intent(Intent.ACTION_VIEW); 
intent.setDataAndType(uri, "application/vnd.ms-powerpoint"); 

PackageManager pm = getPackageManager();
List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
if(list.size() > 0)
   startActivity(context, intent);

其他提示

    File file = new File("path_to_the_file.ppt");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file),"application/vnd.ms-powerpoint");
startActivity(intent);

try with this

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top