it is possible to open a pdf file in the game on android?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Mjhay
Regular
Posts: 61
Joined: Sat Jan 16, 2021 2:29 pm
Location: Philippines
Contact:

it is possible to open a pdf file in the game on android?

#1 Post by Mjhay »

hi everyone ! i need help
it is possible to open a pdf file in the game in android ? i've made a screen button to open the pdf file and in laptop its working but when i build it to apk an install it on my phone, its not working when i clicked the button.

here's my code in script.rpy

label mCOC1:
screen pdf():
vbox:
xalign 0.5
yalign 0.4
textbutton "{u}Open PDF file" action Help("game/resources/coc1.pdf")

2nd problem
i put the pdf file in right directory and its working on laptop but when i build to apk , the directory of pdf file in android/data/resources/coc1.pdf is missing i dont know if it is deleted when building the game or not, so when i clicked the button , nothings happen .
any one can help me here or understand what i mean ? im just a student. i wish someone can help me.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: it is possible to open a pdf file in the game on android?

#2 Post by PyTom »

No, it's not possible to do this on Android. (In general, it's much more complicated for one program to open another on mobile devices.)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
Mjhay
Regular
Posts: 61
Joined: Sat Jan 16, 2021 2:29 pm
Location: Philippines
Contact:

Re: it is possible to open a pdf file in the game on android?

#3 Post by Mjhay »

Ahh i see. Thanks 😊 But even when i use renpy.file() it is not possible yet? Then Can i ask you a suggestion to my problem? I want to make a quiz game and i made a button to read or study the module its a pdf file, so that the user can read or study after taking a quiz . What should i do?

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: it is possible to open a pdf file in the game on android?

#4 Post by _ticlock_ »

Mjhay wrote: Sun Jan 17, 2021 6:25 am I want to make a quiz game and i made a button to read or study the module its a pdf file, so that the user can read or study after taking a quiz . What should i do?
It depends. If it's educational, maybe giving a link to the resource.

You can also turn your file into a number of images and make a screen to show these images as slideshow. Or maybe doing it more fancy and use text-images as overlay on some notebook image.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: it is possible to open a pdf file in the game on android?

#5 Post by PyTom »

I'd suggest hosting the information on a web server, and then using OpenURL to send the user to it. Web servers are a lot less restricted, and so an app can submit a URL to the system to open easily.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
Mjhay
Regular
Posts: 61
Joined: Sat Jan 16, 2021 2:29 pm
Location: Philippines
Contact:

Re: it is possible to open a pdf file in the game on android?

#6 Post by Mjhay »

_ticlock_ wrote: Sun Jan 17, 2021 10:42 am
It depends. If it's educational, maybe giving a link to the resource.

You can also turn your file into a number of images and make a screen to show these images as slideshow. Or maybe doing it more fancy and use text-images as overlay on some notebook image.
Yea i think that, but this module is 700+ pages, if i turn it all to images and make it a slideshow, i think the size of the game will be bigger when it build to apk. Im planning to make this game to be offline .
Last edited by Mjhay on Sun Jan 17, 2021 12:40 pm, edited 1 time in total.

User avatar
Mjhay
Regular
Posts: 61
Joined: Sat Jan 16, 2021 2:29 pm
Location: Philippines
Contact:

Re: it is possible to open a pdf file in the game on android?

#7 Post by Mjhay »

PyTom wrote: Sun Jan 17, 2021 10:51 am I'd suggest hosting the information on a web server, and then using OpenURL to send the user to it. Web servers are a lot less restricted, and so an app can submit a URL to the system to open easily.
Thanks. thats a good idea, 😊 but im planning to to make a offline game . Im stuck on this problem .

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: it is possible to open a pdf file in the game on android?

#8 Post by _ticlock_ »

Mjhay wrote: Sun Jan 17, 2021 12:26 pm Yea i think that, but this module is 700+ pages, if i turn it all to images and make it a slideshow, i think the size of the game will be bigger when it build to apk. Im planning to make this game to be offline.
Well, that is a lot of pages. In this case, the navigation with the slideshow would be inconvenient anyway. Potentially, players could download the file from the provided URL link and later use it offline in a separate app, but that is inconvenient as well :(

User avatar
Mjhay
Regular
Posts: 61
Joined: Sat Jan 16, 2021 2:29 pm
Location: Philippines
Contact:

Re: it is possible to open a pdf file in the game on android?

#9 Post by Mjhay »

_ticlock_ wrote: Sun Jan 17, 2021 6:42 pm
Well, that is a lot of pages. In this case, the navigation with the slideshow would be inconvenient anyway. Potentially, players could download the file from the provided URL link and later use it offline in a separate app, but that is inconvenient as well :(
Yes that right, im really stuck on this .
But I think i should try to provide URL to the player to download the file. But how to do that thing? What should i do?

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: it is possible to open a pdf file in the game on android?

#10 Post by _ticlock_ »

Mjhay wrote: Sun Jan 17, 2021 8:51 pm Yes that right, im really stuck on this .
But I think i should try to provide URL to the player to download the file. But how to do that thing? What should i do?
You need to use action OpenURL as PyTom wrote above. For example:

Code: Select all

screen pdf():
    textbutton _("Open PDF file") action OpenURL("https://www.PATH_TO_FILE/coc1.pdf")

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3792
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: it is possible to open a pdf file in the game on android?

#11 Post by Imperf3kt »

You could possibly direct the player to the file via Android's file://sdcard/ method. Use it with OpenURL

I haven't used this method since around Android 4.4 though so it may no longer be supported.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

User avatar
Mjhay
Regular
Posts: 61
Joined: Sat Jan 16, 2021 2:29 pm
Location: Philippines
Contact:

Re: it is possible to open a pdf file in the game on android?

#12 Post by Mjhay »

Imperf3kt wrote: Mon Jan 18, 2021 7:44 pm You could possibly direct the player to the file via Android's file://sdcard/ method. Use it with OpenURL

I haven't used this method since around Android 4.4 though so it may no longer be supported.
Thanks for that .. 😊
But what about the pdf file? if the game is in the other user ? They dont have the file .

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: it is possible to open a pdf file in the game on android?

#13 Post by PyTom »

In general, writing to the filesystem on Android is something that is hard to get right, with each version getting more and more strict about what you're going to do.

Hosting it on a webserver is likely to work and keep working. Writing to the filesystem is very likely to lead to heartbreak, now and in the future.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: Amazon [Bot], MisterPinetree