Files
android_development/samples/ApiDemos/res/layout/foreground_service_controller.xml
Christopher Tate fc7c9f5d5c Add use of PendingIntent.getForegroundService()
In particular, we have an example of a foreground-service PendingIntent
triggered by a 15-second delayed alarm following a button click.  This
is enough time to exercise use cases like swiping the app out of recents
before the alarm fires, therefore entering the "starting a fg service
when the app is not in a fg state" flows.

Bug: 73559697
Test: this is it
Change-Id: If57908ab852c7a0bfab7bb1da8eda0a47493fc6b
2018-03-19 16:25:01 -07:00

76 lines
3.1 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 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.
-->
<!-- Demonstrates starting and stopping a local service.
See corresponding Java code com.android.sdk.app.LocalSerice.java. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:padding="4dip"
android:gravity="center_horizontal"
android:layout_width="match_parent" android:layout_height="match_parent">
<TextView
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_weight="0" android:paddingBottom="4dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/foreground_service_controller"/>
<Button android:id="@+id/start_foreground"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/start_service_foreground">
<requestFocus />
</Button>
<Button android:id="@+id/start_foreground_wakelock"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/start_service_foreground_wakelock">
</Button>
<Button android:id="@+id/start_background"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/start_service_background">
</Button>
<Button android:id="@+id/start_background_wakelock"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/start_service_background_wakelock">
</Button>
<Button android:id="@+id/stop"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/stop_service">
</Button>
<Button android:id="@+id/start_foreground_2"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/start_service_foreground_2">
</Button>
<Button android:id="@+id/start_foreground_2_alarm"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="@string/start_service_foreground_2_alarm">
</Button>
<Button android:id="@+id/stop_2"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="@string/stop_service_2">
</Button>
</LinearLayout>