导航:
论坛 -> 移动应用开发
斑竹:flyers,iamdream
作者:
2018/10/23 9:25:25
标题:
手机上如何调用其他应用程序打开我下载好了的 EXCEL WORD PDF 等
浏览:1359
加入我的收藏
楼主:
手机上如何调用其他应用程序打开我下载好了的 EXCEL WORD PDF 等
----------------------------------------------
-
作者:
2018/10/23 10:01:15
1楼:
网上一堆的 JAVA 版代码,我们 DELPHI 随便抄就行了。 简单到,连脑子都不用动。
----------------------------------------------
(C)(P)Flying Wang
作者:
2018/10/24 16:55:48
2楼:
楼上就是找骂
----------------------------------------------
-
作者:
2018/11/28 16:47:30
3楼:
OrangeUI\OrangeProjectCommon\uMobileUtils.pas function OpenFile(AForm:TForm;AFilePath:String):Boolean; {$IFDEF IOS} var R:NSRect; WindowHandle:TiOSWindowHandle; {$ENDIF} {$IFDEF ANDROID} var AFileMimeType:String; Intent:JIntent; APublicFilePath:String; {$ENDIF} begin {$IFDEF ANDROID} // AFilePath:='http://115.28.240.141:8020/Reports/TSI.pdf'; // Intent intent = new Intent(); // intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // //设置intent的Action属性 // intent.setAction(Intent.ACTION_VIEW); // //获取文件file的MIME类型 // String type = getMIMEType(file); // //设置intent的data和Type属性。 // intent.setDataAndType(/*uri*/Uri.fromFile(file), type); // //跳转 // startActivity(intent); Intent := TJIntent.JavaClass.init(); Intent.addFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK); //设置intent的Action属性 intent.setAction(TJIntent.JavaClass.ACTION_VIEW); //获取文件file的MIME类型 AFileMimeType:=GetMimeType(ReplaceStr(ExtractFileExt(AFilePath),'.','')); //设置文件 //把文件拷贝到公共目录,不然别的程序访问不了 APublicFilePath:=TPath.GetPublicPath+PathDelim+ExtractFileName(AFilePath); TFile.Copy(AFilePath,APublicFilePath,True); FMX.Types.Log.d('OrangeUI OpenFile AFileMimeType '+AFileMimeType+' APublicFilePath '+APublicFilePath); intent.setDataAndType( TJnet_Uri.JavaClass.fromFile( TJFile.JavaClass.init(StringToJString(APublicFilePath)) ), StringToJString(AFileMimeType)); SharedActivityContext.startActivity(Intent); {$ENDIF} {$IFDEF MSWINDOWS} ShellExecuteW(FmxHandleToHWND(AForm.Handle), nil, PWideChar(AFilePath), PWideChar(''), PWideChar(AFilePath), SW_SHOW); {$ENDIF} {$IFDEF IOS} GlobaldocumentController:=TUIDocumentInteractionController.Wrap( TUIDocumentInteractionController.OCClass .interactionControllerWithURL( TNSURL.Wrap( TNSURL.OCClass.fileURLWithPath( StrToNSStr(AFilePath) ) ) ) ); //interactionControllerWithURL创建的必须来这么一句 GlobaldocumentController.retain; if GlobalUIDocumentInteractionControllerDelegate=nil then begin GlobalUIDocumentInteractionControllerDelegate:=TUIDocumentInteractionControllerDelegate.Create; end; GlobalUIDocumentInteractionControllerDelegate.Form:=AForm; GlobaldocumentController.setDelegate( (GlobalUIDocumentInteractionControllerDelegate as ILocalObject).GetObjectID ); //默认都是0 R.origin.x := 0; R.origin.y := 0; R.size.width := 0; R.size.height := 0; WindowHandle:=WindowHandleToPlatform(AForm.Handle); GlobaldocumentController.presentOpenInMenuFromRect( R, WindowHandle.View, True ); {$ENDIF} end;
----------------------------------------------
-