diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml index 4ec83c3d3..6afdd719b 100644 --- a/samples/ApiDemos/AndroidManifest.xml +++ b/samples/ApiDemos/AndroidManifest.xml @@ -595,6 +595,7 @@ + - + + + + diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml index 78de99f93..963477a14 100644 --- a/samples/ApiDemos/res/values/strings.xml +++ b/samples/ApiDemos/res/values/strings.xml @@ -312,6 +312,7 @@ Start Service Foreground w/Wakelock Start Service Background Start Service Background w/Wakelock + Start Service Foreground 2 App/Service/Isolated Service Controller This demonstrates the use of android:isolatedProcess diff --git a/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.java b/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.java index bbc3c087b..a8c3b868b 100644 --- a/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.java +++ b/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.java @@ -259,6 +259,10 @@ public class ForegroundService extends Service { button.setOnClickListener(mBackgroundWakelockListener); button = (Button)findViewById(R.id.stop); button.setOnClickListener(mStopListener); + button = (Button)findViewById(R.id.start_foreground_2); + button.setOnClickListener(mForegroundListener2); + button = (Button)findViewById(R.id.stop_2); + button.setOnClickListener(mStopListener2); } private OnClickListener mForegroundListener = new OnClickListener() { @@ -299,5 +303,21 @@ public class ForegroundService extends Service { ForegroundService.class)); } }; + + private OnClickListener mForegroundListener2 = new OnClickListener() { + public void onClick(View v) { + Intent intent = new Intent(ForegroundService.ACTION_FOREGROUND); + intent.setClass(Controller.this, ForegroundService2.class); + startService(intent); + } + }; + + private OnClickListener mStopListener2 = new OnClickListener() { + public void onClick(View v) { + stopService(new Intent(Controller.this, + ForegroundService2.class)); + } + }; + } } diff --git a/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService2.java b/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService2.java new file mode 100644 index 000000000..5d7e96cd7 --- /dev/null +++ b/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService2.java @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.android.apis.app; + +public class ForegroundService2 extends ForegroundService { +}