Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add activity-alias support #9654

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .external
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DevDiv/android-platform-support:main@3b4e16f197ff3e102ffb59af0b0f056046cc7658
DevDiv/android-platform-support:main@cc26de2b33292462ab2daa70c593c78ef2a241e7
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace ${ROOT_NAMESPACE}
{
[Register ("${JAVA_PACKAGENAME}.MainActivity"), Activity (Label = "${PROJECT_NAME}", MainLauncher = true, Icon = "@drawable/icon")]
//${ATTRIBUTES}
public class MainActivity : Activity
{
//${FIELDS}
Expand Down
27 changes: 27 additions & 0 deletions tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,33 @@ public void DotNetRun ([Values (true, false)] bool isRelease)
Assert.IsTrue (didLaunch, "Activity should have started.");
}

[Test]
public void ActivityAliasRuns ([Values (true, false)] bool isRelease)
{
var proj = new XamarinAndroidApplicationProject {
IsRelease = isRelease
};
proj.AndroidManifest = proj.AndroidManifest.Replace ("</application>", @"
<activity-alias
android:name="".MainActivityAlias""
android:enabled=""true""
android:icon=""@drawable/icon""
android:targetActivity="".MainActivity""
android:exported=""true"">
<intent-filter>
<action android:name=""android.intent.action.MAIN"" />
<category android:name=""android.intent.category.LAUNCHER"" />
</intent-filter>
</activity-alias>
</application>");
proj.MainActivity = proj.DefaultMainActivity.Replace ("//${ATTRIBUTES}",$"[Register(\"{proj.PackageName}.MainActivity\")]").Replace("MainLauncher = true", "MainLauncher = false");
using var builder = CreateApkBuilder ();
Assert.IsTrue (builder.Install (proj), "Install should have succeeded.");
RunProjectAndAssert (proj, builder);
Assert.True (WaitForActivityToStart (proj.PackageName, "MainActivityAlias",
Path.Combine (Root, builder.ProjectDirectory, "logcat.log"), 30), "Activity MainActivityAlias should have started.");
}

[Test]
public void NativeAssemblyCacheWithSatelliteAssemblies ([Values (true, false)] bool enableMarshalMethods)
{
Expand Down
Loading