Bug 1407961 - Show home after creating PWA.
MozReview-Commit-ID: DM2nvjFrges
--- a/mobile/android/base/java/org/mozilla/gecko/util/ShortcutUtils.java
+++ b/mobile/android/base/java/org/mozilla/gecko/util/ShortcutUtils.java
@@ -1,15 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.util;
import android.annotation.TargetApi;
+import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.IntentSender;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Icon;
import android.graphics.Color;
import android.graphics.Paint;
@@ -84,20 +85,25 @@ public class ShortcutUtils {
.invoke(builder, shortcutIntent);
builderCls.getDeclaredMethod("setShortLabel", CharSequence.class)
.invoke(builder, aTitle != null ? aTitle : aURI);
Object info = builderCls.getDeclaredMethod("build")
.invoke(builder);
+ final Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.addCategory(Intent.CATEGORY_HOME);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ final IntentSender intentSender = pendingIntent.getIntentSender();
mgrCls.getDeclaredMethod("requestPinShortcut",
info.getClass(),
IntentSender.class)
- .invoke(mgr, info, null);
+ .invoke(mgr, info, intentSender);
} catch (Exception e) {
Log.e(LOG_TAG, "Failed to pin shortcut: ", e);
}
// Use this when we can build against SDK 26
//
// final ShortcutManager mgr = context.getSystemService(ShortcutManager.class);