/** * @return * @see android.app.Activity#getCallingPackage() */ public String getCallingPackage() { return mActivity.getCallingPackage(); }
@Override public java.lang.String getCallingPackage() { return mOriginActivity.getCallingPackage(); }
/** * * @param activity * @return The calling application's package name or {@code null} if the activity was not * started with {@link #startActivityForResult} */ public static String getCallingPackageName(Activity activity) { return activity.getCallingPackage(); }
/** * Get the name of the app that started this Activity. * * @param activity * @return The calling application's app name or {@code null} if the activity was not started * with {@link #startActivityForResult} */ public static String getCallingAppName(Activity activity) { final String packageName = activity.getCallingPackage(); if (packageName == null) { return null; } final PackageManager pm = activity.getPackageManager(); try { return pm.getApplicationInfo(packageName, 0).loadLabel(pm).toString(); } catch (NameNotFoundException ignored) { } return null; }
/** * Retrieve the name of the package that launched calledActivity from a share intent. * Apps that provide social sharing functionality can use this to provide attribution * for the app that shared the content. * * <p><em>Note:</em> This data may have been provided voluntarily by the calling * application. As such it should not be trusted for accuracy in the context of * security or verification.</p> * * @param calledActivity Current activity that was launched to share content * @return Name of the calling package */ public static String getCallingPackage(Activity calledActivity) { String result = calledActivity.getCallingPackage(); if (result == null) { result = calledActivity.getIntent().getStringExtra(EXTRA_CALLING_PACKAGE); } return result; }
/** * Retrieve the name of the package that launched calledActivity from a share intent. * Apps that provide social sharing functionality can use this to provide attribution * for the app that shared the content. * * <p><em>Note:</em> This data may have been provided voluntarily by the calling * application. As such it should not be trusted for accuracy in the context of * security or verification.</p> * * @param calledActivity Current activity that was launched to share content * @return Name of the calling package */ public static String getCallingPackage(Activity calledActivity) { String result = calledActivity.getCallingPackage(); if (result == null) { result = calledActivity.getIntent().getStringExtra(EXTRA_CALLING_PACKAGE); } return result; }