made binding of headunit service working
This commit is contained in:
parent
0cf7a7fa52
commit
6a2eddeea6
5 changed files with 18 additions and 5 deletions
|
@ -3,9 +3,8 @@ apply plugin: 'com.android.application'
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 22
|
compileSdkVersion 22
|
||||||
buildToolsVersion "22.0.1"
|
buildToolsVersion "22.0.1"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.esrlabs.headunitservicemock"
|
applicationId 'com.esrlabs.headunitservice'
|
||||||
minSdkVersion 17
|
minSdkVersion 17
|
||||||
targetSdkVersion 22
|
targetSdkVersion 22
|
||||||
versionCode 1
|
versionCode 1
|
||||||
|
@ -17,6 +16,8 @@ android {
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
productFlavors {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.esrlabs.headunitservicemock;
|
package com.esrlabs.headunitservice;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.test.ApplicationTestCase;
|
import android.test.ApplicationTestCase;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.esrlabs.headunitservicemock" >
|
package="com.esrlabs.headunitservice" >
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
@ -11,6 +11,9 @@
|
||||||
android:name=".HeadUnitService"
|
android:name=".HeadUnitService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
android:exported="true" >
|
android:exported="true" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="com.esrlabs.headunitinterface.HeadUnit" />
|
||||||
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.esrlabs.headunitservicemock;
|
package com.esrlabs.headunitservice;
|
||||||
|
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
|
@ -7,6 +7,7 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.esrlabs.headunitinterface.HeadUnit;
|
import com.esrlabs.headunitinterface.HeadUnit;
|
||||||
|
|
||||||
|
@ -18,23 +19,29 @@ import com.esrlabs.headunitinterface.HeadUnit;
|
||||||
* Will use the Android UI instead
|
* Will use the Android UI instead
|
||||||
*/
|
*/
|
||||||
public class HeadUnitService extends Service {
|
public class HeadUnitService extends Service {
|
||||||
|
|
||||||
|
public static final String TAG = "HeadUnitServiceMock";
|
||||||
|
|
||||||
public HeadUnitService() {
|
public HeadUnitService() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinder onBind(Intent intent) {
|
public IBinder onBind(Intent intent) {
|
||||||
|
Log.i(TAG, "onBind");
|
||||||
return binder;
|
return binder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final HeadUnit.Stub binder = new HeadUnit.Stub() {
|
private final HeadUnit.Stub binder = new HeadUnit.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void showNotification(String text) throws RemoteException {
|
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);
|
Notification.Builder builder = new Notification.Builder(getBaseContext()).setContentText(text).setSmallIcon(R.drawable.tum_logo);
|
||||||
notificationService().notify(0,builder.build());
|
notificationService().notify(0,builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hideAllNotifications() throws RemoteException {
|
public void hideAllNotifications() throws RemoteException {
|
||||||
|
Log.i(TAG, "hideAllNotifications");
|
||||||
notificationService().cancelAll();
|
notificationService().cancelAll();
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -1 +1,3 @@
|
||||||
# tum_workshop
|
# tum_workshop
|
||||||
|
|
||||||
|
Collection of our excercises hold at the TUM (Technische Universität München) about automotive and android.
|
||||||
|
|
Loading…
Reference in a new issue