ApiSamples: Add PIP sample
Test: Open ApiSamples > App > Activity > Picture in Picture Change-Id: I205cdc00533b19be46c7837012a96705c7a4a62f
This commit is contained in:
@@ -285,6 +285,18 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".app.PictureInPicture"
|
||||
android:label="@string/activity_picture_in_picture"
|
||||
android:resizeableActivity="true"
|
||||
android:supportsPictureInPicture="true"
|
||||
android:configChanges=
|
||||
"screenSize|smallestScreenSize|screenLayout|orientation">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.SAMPLE_CODE" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".app.PresentationActivity"
|
||||
android:label="@string/activity_presentation">
|
||||
<intent-filter>
|
||||
|
||||
32
samples/ApiDemos/res/layout/picture_in_picture.xml
Normal file
32
samples/ApiDemos/res/layout/picture_in_picture.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright (C) 2018 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 implementation of a DeviceAdmin. -->
|
||||
|
||||
<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">
|
||||
|
||||
<Button android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/enter_pip"
|
||||
android:text="@string/enter_picture_in_picture">
|
||||
|
||||
</Button>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -62,6 +62,9 @@
|
||||
instead of programmatically.</string>
|
||||
<string name="screen_orientation">Screen Orientation</string>
|
||||
|
||||
<string name="activity_picture_in_picture">App/Activity/Picture in Picture</string>
|
||||
<string name="enter_picture_in_picture">Enter picture-in-picture mode</string>
|
||||
|
||||
<string name="activity_translucent">App/Activity/Translucent</string>
|
||||
<string name="translucent_background">Example of how you can make an
|
||||
activity have a translucent background, compositing over
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.example.android.apis.R;
|
||||
|
||||
public class PictureInPicture extends Activity {
|
||||
|
||||
private Button mEnterPip;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.picture_in_picture);
|
||||
|
||||
mEnterPip = (Button)findViewById(R.id.enter_pip);
|
||||
mEnterPip.setOnClickListener((v) -> enterPictureInPictureMode());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onUserLeaveHint() {
|
||||
enterPictureInPictureMode();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user