Posts

Showing posts with the label DashClock Extension

NotificationListenerService and a Whatsapp extension for Dashclock

Image
Android 4.3 (API 18) introduced NotificationListenerService . In this post I'll talk how to use this API, and I'll show how an app can observe the stream of notifications with the user's permission. It is very easy to use a NotificationListenerService. First of all you have to extend NotificationListenerService and implement onNotificationPosted() and onNotificationRemoved() methods public class WhtsNotificationListener extends NotificationListenerService { @Override public void onNotificationPosted(StatusBarNotification sbn) { //.............. } @Override public void onNotificationRemoved(StatusBarNotification sbn) { //.............. } } Then you must declare the service in your manifest file with the BIND_NOTIFICATION_LISTENER_SERVICE permission and include an intent filter with the SERVICE_INTERFACE action Finally user must enable your service. Without t...

How to write a DashClock Extension: Dial Extension example

Image
You can find here a new DashClock Extension example. In previous post I wrote a Battery Extension . This time I tried to make a Dial Extension . We are going to write our service DialExtension that extends the DashClockExtension class. public class DialExtension extends DashClockExtension { private static final String TAG = "DialExtension"; public static final String PREF_FAVORITE_CONTACT = "pref_dial_contact"; // Prefs protected Contact prefContact = null; @Override protected void onUpdateData(int reason) { //Read Preferences readPreferences(); //publish publishUpdateExtensionData(); } /** * publish Update data */ private void publishUpdateExtensionData() { if (prefContact!=null){ //Intent Intent dialIntent = new Intent (Intent.ACTION_DIAL, Uri.parse(prefContact.getPhoneNumber())); // Publish the extension data update. publishUpdate(new ExtensionData() .visible(...

How to write a DashClock Extension: Battery Extension example

Image
With DashClock API it is very easy to write a DashClock Extension. UPDATE 27/05/2013--------------------------------------------------- . You can find it in Google Play. In this github repository you can find a full version. ------------------------------------------------------------------------------ . Here you can find a very simple Battery Extension . This is just an example (bit raw) that should be improved !! . We are going to write our service BatteryExtension that extends the DashClockExtension class. public class BatteryExtension extends DashClockExtension { private static final String TAG = "BatteryExtension"; @Override protected void onUpdateData(int reason) { IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); Intent batteryStatus = getApplicationContext().registerReceiver(null, ifilter); // Level int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); //health //int health = battery...