Improve MultiWindow sample
Now using only one activity able to showcase supported launching options. Added instance counter for better visibility. Bug: 28848683 Change-Id: Ib98dad994d39aff1b617dce4371699c846d06f6f
This commit is contained in:
@@ -26,20 +26,8 @@
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".LaunchingToSideActivity"
|
||||
android:label="Launch To Side"
|
||||
android:resizeableActivity="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".MoveTaskToSideActivity"
|
||||
android:label="Move to side"
|
||||
android:resizeableActivity="true"
|
||||
android:taskAffinity="">
|
||||
<activity android:name=".LaunchingAdjacentActivity"
|
||||
android:label="Launch Adjacent">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
|
||||
43
samples/MultiWindow/res/layout/launching_adjacent_layout.xml
Normal file
43
samples/MultiWindow/res/layout/launching_adjacent_layout.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2015 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.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/instance_number"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/instance_number"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"/>
|
||||
<Button
|
||||
android:id="@+id/launch_settings_adjacent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/launch_settings_adjacent" />
|
||||
<Button
|
||||
android:id="@+id/launch_new_task"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/launch_new_task" />
|
||||
<Button
|
||||
android:id="@+id/launch_new_task_adjacent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/launch_new_task_adjacent" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2015 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.
|
||||
-->
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<Button
|
||||
android:id="@+id/launch_to_the_side"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/launch_settings_to_side"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/launch_new_task"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/launch_new_task"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2015 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.
|
||||
-->
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/launch_settings_to_side"
|
||||
/>
|
||||
</FrameLayout>
|
||||
@@ -15,9 +15,10 @@
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<string name="caption_overlay_activity_hello_text">Hello, World!</string>
|
||||
<string name="caption_overlay_activity_fish_text">Thanks for All the Fish!</string>
|
||||
<string name="launch_settings_to_side">Launch settings to other side</string>
|
||||
<string name="launch_settings_adjacent">Launch settings adjacent</string>
|
||||
<string name="launch_new_task">Launch new task</string>
|
||||
<string name="launch_new_task_adjacent">Launch new task adjacent</string>
|
||||
<string name="instance_number">Instance number:</string>
|
||||
</resources>
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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.multiwindow;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class LaunchingAdjacentActivity extends Activity implements View.OnClickListener {
|
||||
|
||||
private static final String INSTANCE_NUMBER_KEY = "instance_number";
|
||||
|
||||
private static int mInstanceCount;
|
||||
private int mInstanceNumber;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.launching_adjacent_layout);
|
||||
findViewById(R.id.launch_settings_adjacent).setOnClickListener(this);
|
||||
findViewById(R.id.launch_new_task).setOnClickListener(this);
|
||||
findViewById(R.id.launch_new_task_adjacent).setOnClickListener(this);
|
||||
if (savedInstanceState != null) {
|
||||
mInstanceNumber = savedInstanceState.getInt(INSTANCE_NUMBER_KEY);
|
||||
} else {
|
||||
mInstanceNumber = mInstanceCount++;
|
||||
}
|
||||
((TextView) findViewById(R.id.instance_number))
|
||||
.setText(getString(R.string.instance_number) + mInstanceNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.launch_settings_adjacent) {
|
||||
Intent intent = new Intent("android.settings.SETTINGS");
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
|
||||
startActivity(intent);
|
||||
} else if (v.getId() == R.id.launch_new_task) {
|
||||
Intent intent = new Intent(this, LaunchingAdjacentActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
} else if (v.getId() == R.id.launch_new_task_adjacent) {
|
||||
Intent intent = new Intent(this, LaunchingAdjacentActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK
|
||||
| Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle savedInstanceState) {
|
||||
savedInstanceState.putInt(INSTANCE_NUMBER_KEY, mInstanceNumber);
|
||||
super.onSaveInstanceState(savedInstanceState);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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.multiwindow;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
public class LaunchingToSideActivity extends Activity implements View.OnClickListener {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.launching_to_side_layout);
|
||||
findViewById(R.id.launch_to_the_side).setOnClickListener(this);
|
||||
findViewById(R.id.launch_new_task).setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.launch_to_the_side) {
|
||||
Intent intent = new Intent("android.settings.SETTINGS");
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
|
||||
startActivity(intent);
|
||||
} else if (v.getId() == R.id.launch_new_task) {
|
||||
Intent intent = new Intent(this, MoveTaskToSideActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.example.android.multiwindow;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
public class MoveTaskToSideActivity extends Activity implements View.OnClickListener {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.move_task_to_side_layout);
|
||||
findViewById(R.id.button).setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(this, LaunchingToSideActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user