I thought I'd like to share the results of investigations I have carried out today in the hope that some may find it useful. I have an app that stores data as predominantly text and is potentially sharable between a few close groups of people. Rather than create a server and associated comms, I saw a cool way of doing this on an other OS app that used schemes.
So you create a link in an email which contains the data you want to transfer, when it's clicked on a device that recognizes the scheme an intent is generated and an app can be opened in the normal way.
The app I saw used a high level scheme and defined its own which would have been something like 'myapp://" and the data. Apparently this is frowned on by the community as it like creating your own domain name which may cause issues. Added to that, GMail and probably other mail clients actively filter out unrecognized schemes. The next option is to use an existing scheme 'http' and specify a host name which when matched will generate an intent.
To do this, the manifest has to contain similar to the following (as entered with the editor):
The host name can be pretty much anything, but I tried to choose one that wouldn't cause problems i.e. avoided .com etc.
The attached example app simply generates an email that contains a link, when you click on the link the app runs and gets the Intent data into the URI string from where you can parse it as required.
If you want to try the attached app, you need to edit the gmail account and password in SMTP.initialize, add a target valid email address that you can access from the device the app is running on, and amend the mydomain.myd in the Body String to reflect what you have put in the manifest.
I have tested this on Android 4.0 on HTC and Bluestacks.
It is also possible to use links on web pages to transfer data, this will require internet permission and does not work on all browsers, in fact, the only one I have managed to get it to work on is the default browser.
This requires the use of Libraries:
Net
Reflection
It also borrows Erel's SMTP demo verbatim.
So you create a link in an email which contains the data you want to transfer, when it's clicked on a device that recognizes the scheme an intent is generated and an app can be opened in the normal way.
The app I saw used a high level scheme and defined its own which would have been something like 'myapp://" and the data. Apparently this is frowned on by the community as it like creating your own domain name which may cause issues. Added to that, GMail and probably other mail clients actively filter out unrecognized schemes. The next option is to use an existing scheme 'http' and specify a host name which when matched will generate an intent.
To do this, the manifest has to contain similar to the following (as entered with the editor):
B4X:
AddActivityText("main",
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="http" />
<data android:host="mydomain.myd" />
</intent-filter> )
The host name can be pretty much anything, but I tried to choose one that wouldn't cause problems i.e. avoided .com etc.
The attached example app simply generates an email that contains a link, when you click on the link the app runs and gets the Intent data into the URI string from where you can parse it as required.
If you want to try the attached app, you need to edit the gmail account and password in SMTP.initialize, add a target valid email address that you can access from the device the app is running on, and amend the mydomain.myd in the Body String to reflect what you have put in the manifest.
I have tested this on Android 4.0 on HTC and Bluestacks.
It is also possible to use links on web pages to transfer data, this will require internet permission and does not work on all browsers, in fact, the only one I have managed to get it to work on is the default browser.
This requires the use of Libraries:
Net
Reflection
It also borrows Erel's SMTP demo verbatim.
Attachments
Last edited: