Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Deploy and access files with FireMonkey application on Android device?


This question is answered.


Permlink Replies: 8 - Last Post: Jul 12, 2016 7:13 AM Last Post By: Brian Wheatley
Brian Wheatley

Posts: 60
Registered: 2/5/01
Deploy and access files with FireMonkey application on Android device?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 10, 2016 12:00 PM
Hello,

I have followed the instructions in this article - http://community.embarcadero.com/blogs/entry/delphi-xe5--deploying-and-accessing-local-files-on-ios-and-android-43005

I'm using Delphi 10.1 Berlin

I've added my files to the project's deployment page and set the remote path to "assets\internal\vpi\webroot"

This code is in my main form...

procedure TMainForm.FormShow(Sender: TObject);
var
  folder: string;
begin
  // Locate the web page's root folder
{$IF Defined(MSWINDOWS) }
  folder := ExtractFilePath(ParamStr(0));
{$ELSE}
  folder := TPath.GetDocumentsPath + PathDelim + 'VPI' + PathDelim;
{$ENDIF}
 
  folder := folder + 'webroot' + PathDelim + 'login.html';
 
  // Display the path & file name
  Edit1.Text := folder;
 
  if TFile.Exists(folder) then
    Browser.URL := folder;
end;


It runs perfectly on the Windows platform and displays the login.html web page in the browser control.

On the Android platform the web browser does not show the web page and the path shown in the edit box is...

/data/data/com.embarcadero.demo/files/VPI/webroot/login.html

Can someone point me in the right direction as to setting the path?

Thanks!
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Deploy and access files with FireMonkey application on Android device?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 10, 2016 12:58 PM   in response to: Brian Wheatley in response to: Brian Wheatley
Brian wrote:

I have followed the instructions in this article -

That is a community blog. Did you read the official documentation?

http://docwiki.embarcadero.com/RADStudio/en/Deployment_Manager

http://docwiki.embarcadero.com/RADStudio/en/Creating_an_Android_App#Loading_and_Deploying_Files

Also, did you add the System.StartupCopy unit to your 'uses' clause?

--
Remy Lebeau (TeamB)
Brian Wheatley

Posts: 60
Registered: 2/5/01
Re: Deploy and access files with FireMonkey application on Android device?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 11, 2016 7:00 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
Brian wrote:

I have followed the instructions in this article -

That is a community blog. Did you read the official documentation?

http://docwiki.embarcadero.com/RADStudio/en/Deployment_Manager

http://docwiki.embarcadero.com/RADStudio/en/Creating_an_Android_App#Loading_and_Deploying_Files

Also, did you add the System.StartupCopy unit to your 'uses' clause?

--
Remy Lebeau (TeamB)

Remy,

The second article is essentially saying the same thing as the community blog.

I added System.StartupCopy to the uses clause and get the same thing.

I've looked in the Android \ data \ com.embarcadero.com \ folder on the internal memory and on the SD card and do not see the files.
Chris Dunn

Posts: 160
Registered: 8/22/11
Re: Deploy and access files with FireMonkey application on Android device?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 11, 2016 7:58 AM   in response to: Brian Wheatley in response to: Brian Wheatley
I added System.StartupCopy to the uses clause and get the same thing.

The uses clause in your project source file? not in the unit.
Brian Wheatley

Posts: 60
Registered: 2/5/01
Re: Deploy and access files with FireMonkey application on Android device?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 11, 2016 8:09 AM   in response to: Chris Dunn in response to: Chris Dunn
Chris Dunn wrote:
I added System.StartupCopy to the uses clause and get the same thing.

The uses clause in your project source file? not in the unit.

I see it now... yes, it was there
Eli M

Posts: 1,346
Registered: 11/9/13
Re: Deploy and access files with FireMonkey application on Android device?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 11, 2016 6:31 AM   in response to: Brian Wheatley in response to: Brian Wheatley
If you just use assets\internal does it work?
Brian Wheatley

Posts: 60
Registered: 2/5/01
Re: Deploy and access files with FireMonkey application on Android device?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 11, 2016 8:12 AM   in response to: Brian Wheatley in response to: Brian Wheatley
This appears to be an issue with the web browser

To display a file in the Android browser you must start the path with "file://"

The file does not display when the form is shown.

However, I added a "GO!" button and when I click it the browser navigates to the file correctly.
Chris Dunn

Posts: 160
Registered: 8/22/11
Re: Deploy and access files with FireMonkey application on Android device?
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 11, 2016 9:53 AM   in response to: Brian Wheatley in response to: Brian Wheatley
The file does not display when the form is shown.

However, I added a "GO!" button and when I click it the browser navigates to the file correctly.

you can use a timer or handle the startup events

example:

procedure TMainForm.FormCreate(Sender: TObject);
var aFMXApplicationEventService: IFMXApplicationEventService;
begin
if TPlatformServices.Current.SupportsPlatformService(IFMXApplicationEventService, IInterface(aFMXApplicationEventService)) then
aFMXApplicationEventService.SetApplicationEventHandler(HandleAppEvent);
end;

function TMainForm.HandleAppEvent(AAppEvent: TApplicationEvent; AContext: TObject): Boolean;
begin
case AAppEvent of
TApplicationEvent.BecameActive: FStartup;
// TApplicationEvent.WillBecomeInactive: WriteMemo('Will Become Inactive');
// TApplicationEvent.EnteredBackground: WriteMemo('Entered Background');
// TApplicationEvent.WillBecomeForeground: WriteMemo('Will Become Foreground');
// TApplicationEvent.WillTerminate: WriteMemo('Will Terminate');
// TApplicationEvent.LowMemory: WriteMemo('Low Memory');
// TApplicationEvent.FinishedLaunching: FStartup;
TApplicationEvent.TimeChange: ;
TApplicationEvent.OpenURL: FOpenURL(AContext.ToString);
end;
Result := True;
end;
Brian Wheatley

Posts: 60
Registered: 2/5/01
Re: Deploy and access files with FireMonkey application on Android device?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 12, 2016 7:13 AM   in response to: Chris Dunn in response to: Chris Dunn
This is awesome, thanks!
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02