Trusted Web Activity: Is it possible to add file association - android

I have been able to successfully create a TWA from the base instructions provided. It links to the website and works as expected.
However, one of the functionalities of the web app is to upload a particular file type (which is a type of zip) and display its content. That functionality too works as expected and one is able to upload the file, say from the downloads directory to the app and it displays.
What would be desirable is: for the user to tap on the file from the directory (say downloads) and it opens in the App. I am aware of the limitations of access a local file in any web app. But before I tackle that issue I would like to know if there is a way to associate that file extension (or mime-type) with the app. And more importantly how to at least get the path of the file. In the current setup there is no custom Activity java code written. I went by the documentation and put the right settings in the manifest.xml and the site gets loaded.
Thanks.

This is possible by implementing Web Share Target in your Progressive Web App, then enabling it in our Trusted Web Activity.
When using Bubblewrap it will to automatically configure the Trusted Web Activity on init.

Related

Downloading file from S3 on mobile (Android): "Cannot open file"

I'd like to generate a signed link via S3 and then allow a mobile user to download this file. So far this is going okay (downloads with the correct name, filesize, etc).
However - when it comes to opening it (even a .png), I get the message "Cannot open file" and it doesn't turn up in the device's photos, gallery, or anything like that.
Are there some kind of headers missing? Some extra bit of set-up?
The context is a React Native app where the user requests a file, opens the URL via Linking in Chrome, Chrome downloads it, and then they can open it properly. Ideally this will work for any file types (e.g. png, jpg, docx, pdf). Thanks!
If you can't do this in ReactNative, you can always leverage on a native picker. https://developer.android.com/guide/topics/providers/document-provider in any case, there are tons of information to open files in ReactNative with some extensions as: https://github.com/huangzuizui/react-native-file-opener. I tried a couple of them and they work. It should do the job, check the permissions in your application as well. It can be a headers problem so you need to check all of this.

Update offline webpages without updating app

I have an app which contains html files which i am displaying using a webview. This html files are nothing but documentation the users of my app require. My question is, can I update these html files without asking the user to update the entire app? I dont want to replace these html files by hosting the documentaion online.
You will have to do one of these:
Update your app (which is what you don't want)
Host the raw .html files on a web server, and whenever the user opens the app, check if there are new files available and download them.
Simply create a website that shows the .html files and open the
website in your app (which i'm guessing is what you don't want
either)
So you're left with option 2.
To update files without requiring an app update, you will need the app to obtain the HTML content online.
One option, which you mentioned you don't want, is loading a URL into the WebView rather than local HTML files.
The other option would involve hosting the web pages somewhere and the app would download them. The only benefit of this I can see, is that if the device is offline is can use the last obtained HTML file. You could just use caching to achieve this though.
How complicated are the webpages? Using JSON is another method.

Display a pdf that is loaded via webview (android)

I'm looking for a way to display a pdf that is loaded in a webview.
The case is as follows:
- We load a (external) web application inside a webview.
- The web application is secured, users have to login to access their data.
- When the user has logged in there is a button for downloading a pdf file.
- On iOS the pdf file is being displayed inside the webview, on Android it isn't.
- It is not possible to access the pdf by using a webservice instead of the webview (so, Titanium.Network.HTTPClient cannot be used)
We tried several solutions that we found on the internet. Unfortunately, till now without any success.
We tried:
- Google's documentviewer: http://docs.google.com/viewer?embedded=true&url=. This is not working because the pdf is 'behind' a username/password. Google is not aware of the session.
- Saving the pdf to the local file system and open it with Android Intent. We did not succeed in saving the pdf on the local filesystem.
The last option (saving the pdf and open it by using Ti.Android.Intent) seems to be the best option. But is it possible to save a pdf from a webview???
Maybe an external module (or using pdf.js) is also an option.
Can someone point me in the right direction.
We even don't know if what we want is possible?
Any help is really appreciated.
Stefan.

Make app generated content show in stock android Downloads app

We are working on an android app that generates PDFs based on app contents on users' request. We are providing an option to launch an email agent and attach the generate PDF, but we also want the user be able to view the document later at any time. On android, there are no stock file explorer, so our first thought was to show on the stock Downloads app's file list. We've tried the following two methods but without luck.
We firstly tried to save the PDF to the default download folder (given by calling Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS)) and invoke media scanner, but the file doesn't show up in the Downloads app's list. It's shown in Adobe Acrobat's local document list though.
After some research, it seems that the Downloads app would only show files that downloaded though DownloadManager, so we tried to generate the PDF in a temporary directory and call DownloadManager to download it, but, somehow expected, it complains that we can only download via HTTP(S), so this approach isn't working as well.
Is there any other solution?
well if you have to provide access to the document without any file explorer app, i think your approach is correct it to allow to store it in the Download lists. To achive this you can use Nanohttpd in your application to host your pdf document and then invoke the DownloadManager download action using HTTP(S) to your webapp (you will have to create a small webapp to handle the download request) hosted on localhost server.

Android web application on cloud storage

I have a cloud storage website and I want to create an Android application for that website.
I tried 2 methods.
First Method
Using Phonegap to open a remote website which handles everything and its built-in PHP so everything works fine. But a Cloud Storage app must allow uploading and downloading. In Phonegap I can upload through the website but can't download directly to local storage. It can only be done locally if my website is in the local www folder. Also in this way API of Phonegap can't be used either. If I download any file the browser opens up, in this case.
Second Method:
I tried to use Phonegap locally and just create an API of my cloud storage website so that locally with the help of jQuery ,Ajax so that I can post data to the remote URL, but that can't be done due to the Same Origin policy. I may receive the JSON data of files and show but can't log the user in and other features. :( Again a problem.
What else can I do? Is there any other method or solution you can provide me regarding these two methods or any alternative method I can use?
Depending on the kinds of data you're talking about there are several alternatives.
You're describing a cloud storage app (I'm assuming like drop box or Google drive right).
Therefore you'll want to write to the file system instead of some kind of database (locally ofc)
I would therefore check out the following api docs;
http://docs.phonegap.com/en/2.1.0/cordova_file_file.md.html#File
Examples are there too.
PS ive had same origin problems in development, but they seem to go away in production, try testing there too.

Categories

Resources