List of usage examples for android.app Activity getPackageName
@Override
public String getPackageName()
From source file:Main.java
/** * Start the activity./*from w w w . j a v a2 s. co m*/ * * @param activity The activity. * @param clz The activity class. * @param requestCode if >= 0, this code will be returned in * onActivityResult() when the activity exits. */ public static void startActivityForResult(@NonNull final Activity activity, @NonNull final Class<? extends Activity> clz, final int requestCode) { startActivityForResult(activity, null, activity.getPackageName(), clz.getName(), requestCode, null); }
From source file:com.hengtiansoft.ecommerce.library.base.util.PermissionUtils.java
/** * ??/*from ww w . j a v a2 s . co m*/ * * @param cxt * @param req * @return */ @TargetApi(23) public static boolean checkSettingAlertPermission(Object cxt, int req) { if (cxt instanceof Activity) { Activity activity = (Activity) cxt; if (!Settings.canDrawOverlays(activity.getBaseContext())) { LogUtil.i("Setting not permission"); Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + activity.getPackageName())); activity.startActivityForResult(intent, req); return false; } } else if (cxt instanceof Fragment) { Fragment fragment = (Fragment) cxt; if (!Settings.canDrawOverlays(fragment.getActivity())) { LogUtil.i("Setting not permission"); Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + fragment.getActivity().getPackageName())); fragment.startActivityForResult(intent, req); return false; } } else { throw new RuntimeException("cxt is net a activity or fragment"); } return true; }
From source file:Main.java
/** * Start the activity./*w ww . j a v a2s .c o m*/ * * @param extras The Bundle of extras to add to this intent. * @param activity The activity. * @param clz The activity class. * @param requestCode if >= 0, this code will be returned in * onActivityResult() when the activity exits. */ public static void startActivityForResult(@NonNull final Bundle extras, @NonNull final Activity activity, @NonNull final Class<? extends Activity> clz, final int requestCode) { startActivityForResult(activity, extras, activity.getPackageName(), clz.getName(), requestCode, null); }
From source file:Main.java
public static ProgressDialog createProgressDialog(final Activity activity, int progressDialogTitleId, int progressDialogMsgId) { ProgressDialog progressDialog = new ProgressDialog(activity); if (progressDialogTitleId > 0) { progressDialog.setTitle(progressDialogTitleId); } else {// ww w . j a va2 s . c o m progressDialog.setTitle(activity.getResources().getIdentifier(PROGRESS_DIALOG_TITLE_RESOURCE, "string", activity.getPackageName())); } if (progressDialogMsgId > 0) { progressDialog.setMessage(activity.getString(progressDialogMsgId)); } else { progressDialogMsgId = activity.getResources().getIdentifier(PROGRESS_DIALOG_MESSAGE_RESOURCE, "string", activity.getPackageName()); progressDialog.setMessage(activity.getString(progressDialogMsgId)); } progressDialog.setIndeterminate(true); progressDialog.setOnKeyListener(new OnKeyListener() { public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { activity.onKeyDown(keyCode, event); return false; } }); // progressDialog.setInverseBackgroundForced(true); return progressDialog; }
From source file:org.solovyev.android.calculator.App.java
public static void showSystemPermissionSettings(@NonNull Activity activity, @NonNull String action) { try {//from w w w.ja v a2 s . com final Intent intent = new Intent(action); intent.setData(Uri.parse("package:" + activity.getPackageName())); activity.startActivity(intent); } catch (ActivityNotFoundException e) { Log.e(TAG, "Failed to show permission settings for " + action, e); } }
From source file:Main.java
/** * Start the activity.// w ww .j a v a 2 s .co m * * @param activity The activity. * @param clz The activity class. * @param requestCode if >= 0, this code will be returned in * onActivityResult() when the activity exits. * @param options Additional options for how the Activity should be started. */ public static void startActivityForResult(@NonNull final Activity activity, @NonNull final Class<? extends Activity> clz, final int requestCode, final Bundle options) { startActivityForResult(activity, null, activity.getPackageName(), clz.getName(), requestCode, options); }
From source file:com.lvbo.template.common.Utils.PermissionUtils.java
/** * WRITE_SETTINGS ??// ww w . j a v a 2 s .c o m * @param cxt * @param req * @return */ @TargetApi(23) public static boolean checkSettingSystemPermission(Object cxt, int req) { if (cxt instanceof Activity) { Activity activity = (Activity) cxt; if (!Settings.System.canWrite(activity)) { Log.i(TAG, "Setting not permission"); Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS); intent.setData(Uri.parse("package:" + activity.getPackageName())); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activity.startActivityForResult(intent, req); return false; } } else if (cxt instanceof Fragment) { Fragment fragment = (Fragment) cxt; if (!Settings.System.canWrite(fragment.getContext())) { Log.i(TAG, "Setting not permission"); Intent intent = new Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS); intent.setData(Uri.parse("package:" + fragment.getContext().getPackageName())); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); fragment.startActivityForResult(intent, req); return false; } } else { throw new RuntimeException("cxt is net a activity or fragment"); } return true; }
From source file:Main.java
/** * Start the activity./*www . j a v a2 s . c o m*/ * * @param activity The activity. * @param clz The activity class. * @param requestCode if >= 0, this code will be returned in * onActivityResult() when the activity exits. * @param sharedElements The names of the shared elements to transfer to the called * Activity and their associated Views. */ public static void startActivityForResult(@NonNull final Activity activity, @NonNull final Class<? extends Activity> clz, final int requestCode, final View... sharedElements) { startActivityForResult(activity, null, activity.getPackageName(), clz.getName(), requestCode, getOptionsBundle(activity, sharedElements)); }
From source file:Main.java
/** * Start the activity.//from w w w . j a v a 2 s . c o m * * @param extras The Bundle of extras to add to this intent. * @param activity The activity. * @param clz The activity class. * @param requestCode if >= 0, this code will be returned in * onActivityResult() when the activity exits. * @param options Additional options for how the Activity should be started. */ public static void startActivityForResult(@NonNull final Bundle extras, @NonNull final Activity activity, @NonNull final Class<? extends Activity> clz, final int requestCode, @NonNull final Bundle options) { startActivityForResult(activity, extras, activity.getPackageName(), clz.getName(), requestCode, options); }
From source file:Main.java
/** * Start the activity.//from ww w . j a v a 2 s . co m * * @param extras The Bundle of extras to add to this intent. * @param activity The activity. * @param clz The activity class. * @param requestCode if >= 0, this code will be returned in * onActivityResult() when the activity exits. * @param sharedElements The names of the shared elements to transfer to the called * Activity and their associated Views. */ public static void startActivityForResult(@NonNull final Bundle extras, @NonNull final Activity activity, @NonNull final Class<? extends Activity> clz, final int requestCode, final View... sharedElements) { startActivityForResult(activity, extras, activity.getPackageName(), clz.getName(), requestCode, getOptionsBundle(activity, sharedElements)); }