Communication between main firemonkey application and local service - android

I've got a Firemonkey application with a Local Android Service.
When the user opens it, he has to write something in a TEdit and when he clicks an OK button, the application starts the local android service :
FLocationServiceConn := TLocalServiceConnection.Create; // -- android_service
FLocationServiceConn.StartService('LocationService'); // -- android_service
The service sends user's location to a remote server using a nethttpclient object.
The problem is that I need to send TEdit.Text info with the user's location to the remote server (I need to know which is the user), so I need to pass that info to the service when it starts.
I haven't found how to pass parameters to a local service. I have tried to create a file when the user clicks OK button (it works)
miau:=TStringList.Create;
miau.Text:='test';
miau.SaveToFile(TPath.Combine(TPath.GetDocumentsPath, 'conf.txt'));
but when I try to read that file from the service, it crashes...(It seems TPath is the problem).
What do you think? Which would be the best way to send the users info (TEdit.Text) to the local service?
Thank you very much

Related

Asterisk call flow

I want to use asterisk server for SIP/VOIP calls from/to android app. I searched for good Sip client and found CSip simple is good.
Suppose there are 2 users A and B.
when A wants to call to B,
A sends request to internal server
Internal server will check if A can call B or not by populating some database value
If yes, Server will ask B if it wants to accept call from A
If yes, server will setup call between A and B
How i should configure these things in asterisk to achieve this and also like to know that if CSipSimple will be best for android?
If i am wrong anywhere please correct me.
Thanks
CSipSimple will be best for android.
For asterisk i try to solve your problem. Try below configuration to make call.
Suppose there are 2 users A and B.
A user server
Modified A server extension.conf
[my_outgoing]
//exten => _X.,1,Dial(SIP/${EXTEN})
exten => _X.,1,AGI(test.php)
// test.php is check for balance of A and if A having enough balance then it will call B from this file it self
Modified A server sip.conf
[2221]
username=2221
type=friend
secret=2221
host=dynamic
context=my_outgoing
Modified B server extension.conf
[my_incoming]
//exten => _X.,1,Answer()
exten => _X.,1,AGI(test2.php)
// Here test2.php is for run IVR from script and give user for press 1 or 2 to accept and reject the call etc...
// if you are using the real device or soft phone then it will handle the call option by it self
// If you have to handle this using script then code to handle call written into this
// And if GUI [from soft phone] is there to handle call then write bellow line only
exten => _X.,1,Dial(SIP/${EXTEN})
Modified B server sip.conf
[2222]
username=2222
type=friend
secret=2222
host=dynamic
context=default
Now try to register both user from different device and try to make call.
Call from A(2221) to B(2222)

how can I input information data when app is in first startup?

I want input data in internal storage of my app when my app installed in new device & never change(delete & update &insert). my information is heavy & if I input my information in oncreate() every time that user open my app information will be make again & I don't like it.how can I do it?
Create a class that is a Broadcastreceiver and register it in your manifest to receiver Intent.ACTION_PACKAGE_INSTALL actions. It will be called only when the application is installed.
You can use assets folder and put your heavy data there. It will be installed with application package. You can find information about that here.

Start Android application from NFC-tag with extra data

I can start my application by simply putting the phone on a NFC-tag. But I would like to take the idea one step further. Imagine a simple time-tracking application with two NFC-tags. The first will start (and download) the application and register a starttime. The other will also start (and download) the application, but register a stoptime.
My problem I'd like to solve is that I don't want my phone to know about these tags. The application should not need to have a list of tag-ids programmed and know what actions that is connected to each id. The tag should carry the information needed to start the action on the phone with the correct parameters.
Are there any information about how to accomplish this scenario? I have installed "nfc-eclipse-plugin" but doesn't understand how to use it to get my goal and even less how to get my application to read the extra data.
Thanks in advance
Roland
Your tags should be capable of storing NDEF messages. Such messages are automatically read out by Android and passed to your app in an Intent. Automatically installing and/or starting your app can be accomplished by putting an Android Application Record in your tag. Any additional information ("start" or "stop" indication) can be stored in a proprietary record.
You probably want to put the AAR as the last record of the NDEF message, as it is detected and acted upon by Android automatically, but is only supported since ICS. To make automatic installation work with Gingerbread, you can put an additional URI record or SmartPoster record with a Google Play Store link in it as the first record of the message. Your app should then filter (ACTION_NDEF_DISCOVERED) for this URI, so it will also start automatically on Gingerbread.

How to know if my Android SmartWatch extension is inactive?

I'm developing a RSS smart extension app using the Notification API.
I would like to know how to get the active/inactive status of my smart extension (the first checkbox when clicking on my RSS smart extension in the SmartWatch app).
The NotificationAPI sample uses an extra Checkbox preference to start or not a service downloading data generating notifications, but I don't want to force the user to go into a sub menu and activate the download of data. If the user activates my RSS smart extension, he already expects the extension to notify him if there's some new items into the RSS.
There's a callback to know when my smart extension is correctly added to liveware/smartwatch apps (onRegisterResult), but I didn't find the callback to know if the smart extension is actually active or not.
Thanks in advance!
The SampleNotificationExtension of the Smart Extension SDK has been provided to give some examples on:
how to add/update/remove/read data to/from the Notification database that resides in the Liveware Manager application (which is the hub of the Smart Extension API) through a content provider
how to respond to the event that the user opens a Notification on the SmartWatch and e.g. presses the action button
In the example extension, there is a service that is feeding the Notification database each 10 seconds, which is then shown on the SmartWatch device. The on/off setting in the preference activity is just for starting and stopping the loop that feeds the database.
Ok.
So I guess you want to subscribe to RSS feeds, and when new posts arrive, you want them to be propagated to the SmartWatch. You probably need start a service, like in the example, and you probably should have the service running as long as the watch is connected to the phone. This you can specify here:
#Override
protected boolean keepRunningWhenConnected() {
return true;
}
If you use the SmartExtension utility classes, your extension will automagically be registered and your service will be started. In the sample extension, after the extension has been registered, a check is done to see if the user has activated the extension via the preferences.
#Override
public void onRegisterResult(boolean result) {
/.../
boolean isActive = prefs.getBoolean(
getString(R.string.preference_key_is_active), false);
if (isActive) {
startAddData();
}
}
You could keep this if you want, but it is not required. As stated before, its just for starting and stopping the data feeding. Anyways, you could start a RSS check after registration.
If the user activates my RSS smart extension, he already expects the extension to notify him if there's some new items into the RSS.
When the service starts, you can check a delta between what is in the notification database, and what is fed from the RSS feed.
WELL, a long answer, hope it helps!

Control an application from another application

I read this question and another question and I understand how to launch an application from another application (Let's call the other application LauncherApplication). However, my goal is not only to launch an application, but to use its functions, so I suppose the LauncherApplication should start an activity using an intent (explicit or implicit).
I should know the data and the actions the installed applications react on and I should add these information to an intent instance before starting it. I wish LauncherApplication allows the user (not the developer) to configure this intent, but how do I know in advance the parameters to put in an intent for the installed applications?
I should implement the "LauncherApplication* in order to allow the user to construct an intent via a graphical interface. Or I could make my application supports the addition of plugins: in this way, I could create a plugin for each installed application, where each plugin could be responsible to manage the configuration of the intent concerning the application associated with it.
UPDATE (added details). In particular, the LauncherApplication should be a service with a speech recognizer enabled, so the user may start an application uttering specific keywords: as well as launch an application, the user should be able to close it and use its functions.
For example, I could have installed an application ((Let's call it LibraryApp) to search for available books in a library; this application could have the following functions:
Search for a book (this function may return if the book is available, it has already been loaned or if it was booked by someone else).
Reserving a book (this function should return the completion of the reservation).
In this way, when I pronounce, for example, the words "start LibraryApp", then the LauncherApplication service should launch the LibraryApp application. Once the application is launched, the service should be able to send commands to it to use one of the available functions (search for a book, reserving a book).
How can I send commands to application that is already active, in order to control it?
how do I know in advance the parameters to put in an intent for the installed applications?
You talk to their developers. There are typically zero "parameters" on an Intent to launch the launcher activity (or activities) of an application, since home screens do not put such "parameters" on the Intent.

Categories

Resources