sl4a python notify question
Asked Answered
H

1

9

I have two questions regarding the sl4a scripting language. I'd like to develop a python script that will be periodically contacted by a server and post some information to the notification bar.

I've successfully add message to the notification bar, but

  1. The notification icon is always sl4a logo. Is there a way to change it to something else? (I don't mind to use some hack method such as rename the resource file, if that will work...)
  2. When I click the notification, it just remove the message. I'd like to add some intent that would take the user to certain app or webpage. Is it possible?

Thanks!

Hinkel answered 29/8, 2011 at 2:6 Comment(0)
U
3
  1. Officially, there is no API exposed to SL4A for customization of notifications which exist does exist in Android.
    Reference: http://developer.android.com/guide/topics/ui/notifiers/notifications.html#CustomExpandedView http://code.google.com/p/android-scripting/wiki/ApiReference

  2. Officially, there is no API exposed to SL4a for firing an intent on user click from user. .

    notify(
     String title: title,
     String message)
    

Notify, just displays a notification that will be canceled when the user clicks on it. Now, somehow if you can trace cancellation of this notification, you can start a new intent using your script.

Hack?

Please note, Android treats these notification from SL4A and not from your script. (due to which you are getting the SL4A icon) Thus, somehow it is possible to use all API which are exposed to a normal JAVA code, treating SL4A as an application but then this approach will make all your apps using SL4a have the same logo. ;)

Underbred answered 29/8, 2011 at 2:7 Comment(4)
I think it does matter whether I'm using Python via SL4A or Java directly, because in SL4A, I can only use the APIs exposed by the SL4A to communicate with the system. While in Java, I have all the Android API I can use to create custom notification.Hinkel
Sorry, based on your answer, I still have no idea how to implement custom notification icon from Python... Looks like this is for someone with access to Java interface.Hinkel
@Patrick: I have improved my answer and hope is able to help you.Forebode
Looks like I may need to modify SL4A code to change the notification behavior ... Thanks for the update!Hinkel

© 2022 - 2024 — McMap. All rights reserved.