use of android.content.IntentSender in project android_packages_apps_Settings by LineageOS.
the class NotificationStation method formatPendingIntent.
private static String formatPendingIntent(PendingIntent pi) {
final StringBuilder sb = new StringBuilder();
final IntentSender is = pi.getIntentSender();
sb.append("Intent(pkg=").append(is.getCreatorPackage());
try {
final boolean isActivity = ActivityManager.getService().isIntentSenderAnActivity(is.getTarget());
if (isActivity)
sb.append(" (activity)");
} catch (RemoteException ex) {
}
sb.append(")");
return sb.toString();
}
use of android.content.IntentSender in project Rocket by mozilla-tw.
the class ShortcutUtils method requestPinShortcut.
// Request pinned shortcut for both API level
public static void requestPinShortcut(@NonNull final Context context, @NonNull final Intent shortcutIntent, @NonNull final String title, @NonNull final String urlAsShortcutId, final Bitmap bitmap) {
final Bitmap icon;
final Resources resources = context.getResources();
final char representativeCharacter = FavIconUtils.getRepresentativeCharacter(urlAsShortcutId);
if (bitmap == null) {
// if favicon is not ready, we use the default initial icon with white color
icon = FavIconUtils.getInitialBitmap(resources, null, representativeCharacter);
} else {
// if favicon is ready, resize it using size that fits shortcut better
icon = FavIconUtils.getRefinedShortcutIcon(resources, bitmap, representativeCharacter);
}
// label must not be empty
String label = title;
if (TextUtils.isEmpty(title)) {
label = urlAsShortcutId;
}
final ShortcutInfoCompat shortcut = new ShortcutInfoCompat.Builder(context, urlAsShortcutId).setShortLabel(label).setIcon(IconCompat.createWithBitmap(icon)).setIntent(shortcutIntent).build();
// Display home screen after add to home screen
final Intent showHome = new Intent(Intent.ACTION_MAIN);
showHome.addCategory(Intent.CATEGORY_HOME);
showHome.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, showHome, PendingIntent.FLAG_UPDATE_CURRENT);
final IntentSender intentSender = pendingIntent.getIntentSender();
// TODO: find a way to update the shortcut icon for API 25-. Currently the only way is remove old shortcut and add again.
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {
final ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class);
if (shortcutManager != null) {
final List<ShortcutInfo> list = new ArrayList<>();
list.add(shortcut.toShortcutInfo());
shortcutManager.updateShortcuts(list);
}
}
// If the launcher or system didn't support shortcut, we don't bother to call it.
if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) {
ShortcutManagerCompat.requestPinShortcut(context, shortcut, intentSender);
}
}
use of android.content.IntentSender in project android_packages_apps_Settings by omnirom.
the class ChooseLockSettingsHelper method copyOptionalExtras.
private void copyOptionalExtras(Intent inIntent, Intent outIntent) {
IntentSender intentSender = inIntent.getParcelableExtra(Intent.EXTRA_INTENT);
if (intentSender != null) {
outIntent.putExtra(Intent.EXTRA_INTENT, intentSender);
}
int taskId = inIntent.getIntExtra(Intent.EXTRA_TASK_ID, -1);
if (taskId != -1) {
outIntent.putExtra(Intent.EXTRA_TASK_ID, taskId);
}
// TODO: Remove once that bug is fixed.
if (intentSender != null || taskId != -1) {
outIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
outIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
}
}
use of android.content.IntentSender in project android_packages_apps_Settings by crdroidandroid.
the class ConfirmDeviceCredentialBaseFragment method checkForPendingIntent.
protected void checkForPendingIntent() {
int taskId = getActivity().getIntent().getIntExtra(Intent.EXTRA_TASK_ID, -1);
if (taskId != -1) {
try {
IActivityManager activityManager = ActivityManager.getService();
final ActivityOptions options = ActivityOptions.makeBasic();
options.setLaunchStackId(ActivityManager.StackId.INVALID_STACK_ID);
activityManager.startActivityFromRecents(taskId, options.toBundle());
return;
} catch (RemoteException e) {
// Do nothing.
}
}
IntentSender intentSender = getActivity().getIntent().getParcelableExtra(Intent.EXTRA_INTENT);
if (intentSender != null) {
try {
getActivity().startIntentSenderForResult(intentSender, -1, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
/* ignore */
}
}
}
use of android.content.IntentSender in project android_packages_apps_Settings by SudaMod.
the class ChooseLockSettingsHelper method copyOptionalExtras.
private void copyOptionalExtras(Intent inIntent, Intent outIntent) {
IntentSender intentSender = inIntent.getParcelableExtra(Intent.EXTRA_INTENT);
if (intentSender != null) {
outIntent.putExtra(Intent.EXTRA_INTENT, intentSender);
}
int taskId = inIntent.getIntExtra(Intent.EXTRA_TASK_ID, -1);
if (taskId != -1) {
outIntent.putExtra(Intent.EXTRA_TASK_ID, taskId);
}
// TODO: Remove once that bug is fixed.
if (intentSender != null || taskId != -1) {
outIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
outIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
}
}
Aggregations