Fix not able to add Settings shortcut widget problem

After users select a shortcut item in CreateShortcutActivity,
launchers need to get result from CreateShortcutActivity.

For large screen devices, Settings deep link will start
DeepLinkHomepageActivity and then DeepLinkHomepageActivity
starts the deep link page. The CreateShortcutActivity result
deos not forward to launcher and there is no shortcut added.

This change uses Intent.FLAG_ACTIVITY_FORWARD_RESULT to
forward result from CreateShortcutActivity to launcher.

Bug: 200889769
Test: manual
      Long click launcher -> Widget -> Settings ->
      select an item and check if it adds a short on launcher.
Change-Id: Idd5fc642be5c1fb2f747316c3ddcd9b7f0b33852
This commit is contained in:
Arc Wang
2021-09-23 14:47:15 +08:00
parent 4223ee98ea
commit 4dd3f11349
2 changed files with 2 additions and 0 deletions

View File

@@ -384,6 +384,7 @@ public class SettingsActivity extends SettingsBaseActivity
trampolineIntent.putExtra(
android.provider.Settings.EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_URI,
intent.toUri(Intent.URI_INTENT_SCHEME));
trampolineIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
startActivity(trampolineIntent);
return true;

View File

@@ -212,6 +212,7 @@ public class SettingsHomepageActivity extends FragmentActivity implements
intent.setAction(null);
targetIntent.setFlags(targetIntent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK);
targetIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
// Sender of intent may want to send intent extra data to the destination of targetIntent.
targetIntent.replaceExtras(intent);