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!
Related
I want to change the text "Default Media Receiver" which is displayed on the audio playback page of the Chromecast Default Media Receiver, but not the video playback page, to anything but that. I'm developing an Android app.
I'm having difficulty getting my website hosting service to enable SSL. They won't do it unless I upgrade to dedicated IP address even for a self-signed cert, at considerable expense). So I'm stuck with a choice between styled receiver/no stylesheet, and the Default Media Receiver. (Yes, a change of hosting services is in the wind. Don't ask).
I rather prefer the appearance of the Default Media Receiver. It starts up faster, and the Cast icon on the startup page instead of my app name is nicer.
Except for one small irritating detail. When playing audio tracks on the Default Media Receiver, the title of the application ("Default Media Receiver") is displayed on the otherwise very beautiful page on the Chromecast device when playing audio tracks.
Is there any way to change this without resorting to a styled media receiver?
(eyeroll directed to response in comment...Here's the code. I already described what I tried.)
#Override
public CastOptions getCastOptions(Context context) {
return new CastOptions.Builder()
// Use this line for styled/no-style-sheet.
//.setReceiverApplicationId(context.getString(R.string.cast_app_id))
// use this line for default receiver.
.setReceiverApplicationId(
CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID)
.build();
}
There is now an option to use a "Styled Media Receiver" without having to serve content from your own Web Servers.
Go to your Application registration on the Google Cast DSK Developer site. Edit your application details to be a "Styled Media Receiver", and leave the "Skin URL" blank. Edit the rest of the details accordingly. The name you supplied in the App registration details will show as the ChromeCast device connects to your app. And your app logo will appear in the place in the Chromecast UI that used to say "Default Media Receiver".
You must also make sure you have the following code:
public CastOptions getCastOptions(Context context) {
return new CastOptions.Builder()
.setReceiverApplicationId(context.getString("YOUR APPLICATION ID"))
.build();
}
And you must (of course) PUBLISH the changes you made to the Application Registration (or add your phone as a test device).
This is not currently possible. I have filed a feature request for this here: https://issuetracker.google.com/issues/156888250
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
I tried using a Android phone to cast to Chromecast device by Youtube app. I added some Videos to queue, then I used another phone to cast to Chromecast device. The second one automatically knows the videos added to queue on the first one.
I don't know how Youtube app can do this?
EDIT I guess Youtube app uses one custom data channel besides Media channel. When Video is added to queue, sender app will send somethings (eg: videoId) to receiver. Receiver will save it in array of video ID. When another phone connects to Chromecast device, It'll receiver array of video ID from the receiver. Can anyone give other solutions? Thanks
I guess what you are asking is how you can create a play list, potentially shared by multiple devices. If that is the case, you have a couple of choices:
keep the playlist in the receiver: this is the simplest option. This will be a simple array on the receiver, kept in memory, which will go away when application ends. A custom receiver is required and it can implement the methods such as "append, insert, get, clear, ... to provide what the senders need. When each sender connects, it can ask (calling 'get' for example) for the current "queue" and then can modify the queue by other methods such as 'clear', 'append', 'insert', .... Note that there is no long-term persistence on the receiver (local storage is available but will be cleared as son as the app is gone).
keep the playlist in the cloud: you need to do most of the things that you do in the previous option but you also persist the playlist to the cloud; the advantage is that playlist lasts beyond the life of a session (this may or may not be desired). In addition, sender apps can potentially get the playlist fro the cloud directly, if needed.
The important thing is that the main storage for your playlist is not your sender devices; they don't know (and shouldn't know) abut the presence of other senders in the eco-system.
On the receiver side, we recently published a simple sample that sows how the notion of (local) playlist can be implemented; that is a simplified example but is enough to show that with minimal work, you can take advantage of the Media Channel; for more sophisticated handling of a shared queue, you definitely need an out-of-bound channel/namespace to handle all the additional api's that I mentioned above.
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.
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.