添加多窗口支持与LogActivity独立任务栈
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Mon Apr 27 19:22:37 CST 2026
|
||||
#Mon Apr 27 19:57:40 CST 2026
|
||||
stageCount=20
|
||||
libraryProject=libappbase
|
||||
baseVersion=15.15
|
||||
publishVersion=15.15.19
|
||||
buildCount=26
|
||||
buildCount=34
|
||||
baseBetaVersion=15.15.20
|
||||
|
||||
@@ -41,6 +41,17 @@
|
||||
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".Main2Activity"
|
||||
android:label="@string/app_name"
|
||||
android:exported="true"
|
||||
android:resizeableActivity="true"
|
||||
android:launchMode="singleTop"
|
||||
android:taskAffinity="cc.winboll.studio.appbase.Main2Activity"
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation">
|
||||
|
||||
</activity>
|
||||
|
||||
<activity android:name=".GlobalApplication$CrashActivity"/>
|
||||
|
||||
<meta-data
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package cc.winboll.studio.appbase;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toolbar;
|
||||
import cc.winboll.studio.appbase.R;
|
||||
|
||||
public class Main2Activity extends MainActivity {
|
||||
|
||||
public static final String TAG = "Main2Activity";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main2);
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
if (toolbar != null) {
|
||||
setActionBar(toolbar);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,5 +181,15 @@ public class MainActivity extends Activity {
|
||||
LogUtils.d(TAG, "onSplitScreenMode() MainActivityAlias已启动");
|
||||
}
|
||||
}
|
||||
|
||||
public void onMultiInstance(View view) {
|
||||
LogUtils.d(TAG, "onMultiInstance() 多开窗口按钮已点击");
|
||||
ToastUtils.show("多开窗口:已启动新窗口");
|
||||
android.content.Intent intent = new android.content.Intent(this, Main2Activity.class);
|
||||
intent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
LogUtils.d(TAG, "onMultiInstance() 准备启动Main2Activity");
|
||||
startActivity(intent);
|
||||
LogUtils.d(TAG, "onMultiInstance() Main2Activity已启动");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,18 @@
|
||||
android:onClick="onSplitScreenMode"
|
||||
android:layout_margin="10dp"/>
|
||||
|
||||
<Button
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="多开窗口"
|
||||
android:textSize="16sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:background="#81C7F5"
|
||||
android:paddingVertical="12dp"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:onClick="onMultiInstance"
|
||||
android:layout_margin="10dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
17
appbase/src/main/res/layout/activity_main2.xml
Normal file
17
appbase/src/main/res/layout/activity_main2.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:background="@android:color/white">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Main2Activity"
|
||||
android:textSize="24sp"
|
||||
android:textColor="@color/gray_900"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,8 +1,8 @@
|
||||
#Created by .winboll/winboll_app_build.gradle
|
||||
#Mon Apr 27 19:22:37 CST 2026
|
||||
#Mon Apr 27 19:57:40 CST 2026
|
||||
stageCount=20
|
||||
libraryProject=libappbase
|
||||
baseVersion=15.15
|
||||
publishVersion=15.15.19
|
||||
buildCount=26
|
||||
buildCount=34
|
||||
baseBetaVersion=15.15.20
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
android:resizeableActivity="true"
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTop"
|
||||
android:launchMode="singleInstance"
|
||||
android:taskAffinity="cc.winboll.studio.libappbase.LogActivity"
|
||||
android:process=":LogActivity">
|
||||
|
||||
</activity>
|
||||
|
||||
@@ -59,16 +59,14 @@ public class LogActivity extends Activity {
|
||||
*/
|
||||
public static void startLogActivity(Context context, boolean newTask) {
|
||||
Intent intent = new Intent(context, LogActivity.class);
|
||||
intent.setFlags(0);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
||||
if (newTask) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
context.startActivity(intent);
|
||||
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
|
||||
|
||||
@@ -82,7 +80,6 @@ public class LogActivity extends Activity {
|
||||
options.setLaunchBounds(bounds);
|
||||
context.startActivity(intent, options.toBundle());
|
||||
} else {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user