made binding of headunit service working

This commit is contained in:
florian.bramer 2015-06-15 20:11:08 +02:00
parent 0cf7a7fa52
commit 6a2eddeea6
5 changed files with 18 additions and 5 deletions

View file

@ -3,9 +3,8 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.esrlabs.headunitservicemock"
applicationId 'com.esrlabs.headunitservice'
minSdkVersion 17
targetSdkVersion 22
versionCode 1
@ -17,6 +16,8 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {

View file

@ -1,4 +1,4 @@
package com.esrlabs.headunitservicemock;
package com.esrlabs.headunitservice;
import android.app.Application;
import android.test.ApplicationTestCase;

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.esrlabs.headunitservicemock" >
package="com.esrlabs.headunitservice" >
<application
android:allowBackup="true"
@ -11,6 +11,9 @@
android:name=".HeadUnitService"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="com.esrlabs.headunitinterface.HeadUnit" />
</intent-filter>
</service>
</application>

View file

@ -1,4 +1,4 @@
package com.esrlabs.headunitservicemock;
package com.esrlabs.headunitservice;
import android.app.Notification;
import android.app.NotificationManager;
@ -7,6 +7,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import com.esrlabs.headunitinterface.HeadUnit;
@ -18,23 +19,29 @@ import com.esrlabs.headunitinterface.HeadUnit;
* Will use the Android UI instead
*/
public class HeadUnitService extends Service {
public static final String TAG = "HeadUnitServiceMock";
public HeadUnitService() {
}
@Override
public IBinder onBind(Intent intent) {
Log.i(TAG, "onBind");
return binder;
}
private final HeadUnit.Stub binder = new HeadUnit.Stub() {
@Override
public void showNotification(String text) throws RemoteException {
Log.i(TAG, "showNotification '" + text + "'");
Notification.Builder builder = new Notification.Builder(getBaseContext()).setContentText(text).setSmallIcon(R.drawable.tum_logo);
notificationService().notify(0,builder.build());
}
@Override
public void hideAllNotifications() throws RemoteException {
Log.i(TAG, "hideAllNotifications");
notificationService().cancelAll();
}
};

View file

@ -1 +1,3 @@
# tum_workshop
Collection of our excercises hold at the TUM (Technische Universität München) about automotive and android.