use of android.content.IntentSender in project android_packages_apps_Settings by omnirom.
the class AccountSyncSettings method requestAccountAccessIfNeeded.
private boolean requestAccountAccessIfNeeded(String packageName) {
if (packageName == null) {
return false;
}
final int uid;
try {
uid = getContext().getPackageManager().getPackageUidAsUser(packageName, mUserHandle.getIdentifier());
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Invalid sync ", e);
return false;
}
AccountManager accountManager = getContext().getSystemService(AccountManager.class);
if (!accountManager.hasAccountAccess(mAccount, packageName, mUserHandle)) {
IntentSender intent = accountManager.createRequestAccountAccessIntentSenderAsUser(mAccount, packageName, mUserHandle);
if (intent != null) {
try {
startIntentSenderForResult(intent, uid, null, 0, 0, 0, null);
return true;
} catch (IntentSender.SendIntentException e) {
Log.e(TAG, "Error requesting account access", e);
}
}
}
return false;
}
use of android.content.IntentSender in project android_packages_apps_Settings by omnirom.
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 omnirom.
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 android_packages_apps_Settings by DirtyUnicorns.
the class AccountSyncSettings method requestAccountAccessIfNeeded.
private boolean requestAccountAccessIfNeeded(String packageName) {
if (packageName == null) {
return false;
}
final int uid;
try {
uid = getContext().getPackageManager().getPackageUidAsUser(packageName, mUserHandle.getIdentifier());
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Invalid sync ", e);
return false;
}
AccountManager accountManager = getContext().getSystemService(AccountManager.class);
if (!accountManager.hasAccountAccess(mAccount, packageName, mUserHandle)) {
IntentSender intent = accountManager.createRequestAccountAccessIntentSenderAsUser(mAccount, packageName, mUserHandle);
if (intent != null) {
try {
startIntentSenderForResult(intent, uid, null, 0, 0, 0, null);
return true;
} catch (IntentSender.SendIntentException e) {
Log.e(TAG, "Error requesting account access", e);
}
}
}
return false;
}
use of android.content.IntentSender in project android_packages_apps_Settings by crdroidandroid.
the class AccountSyncSettings method requestAccountAccessIfNeeded.
private boolean requestAccountAccessIfNeeded(String packageName) {
if (packageName == null) {
return false;
}
final int uid;
try {
uid = getContext().getPackageManager().getPackageUidAsUser(packageName, mUserHandle.getIdentifier());
} catch (PackageManager.NameNotFoundException e) {
Log.e(TAG, "Invalid sync ", e);
return false;
}
AccountManager accountManager = getContext().getSystemService(AccountManager.class);
if (!accountManager.hasAccountAccess(mAccount, packageName, mUserHandle)) {
IntentSender intent = accountManager.createRequestAccountAccessIntentSenderAsUser(mAccount, packageName, mUserHandle);
if (intent != null) {
try {
startIntentSenderForResult(intent, uid, null, 0, 0, 0, null);
return true;
} catch (IntentSender.SendIntentException e) {
Log.e(TAG, "Error requesting account access", e);
}
}
}
return false;
}
Aggregations