本文整理了Java中android.app.Activity.getCallingPackage()
方法的一些代码示例,展示了Activity.getCallingPackage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.getCallingPackage()
方法的具体详情如下:
包路径:android.app.Activity
类名称:Activity
方法名:getCallingPackage
暂无
代码示例来源:origin: com.uphyca/android-junit4-robolectric
/**
* @return
* @see android.app.Activity#getCallingPackage()
*/
public String getCallingPackage() {
return mActivity.getCallingPackage();
}
代码示例来源:origin: iqiyi/Neptune
@Override
public java.lang.String getCallingPackage() {
return mOriginActivity.getCallingPackage();
}
代码示例来源:origin: stackoverflow.com
/**
*
* @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();
}
代码示例来源:origin: stackoverflow.com
/**
* 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;
}
代码示例来源:origin: com.google.android/support-v4
/**
* 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;
}
代码示例来源:origin: kingargyle/adt-leanback-support
/**
* 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;
}
内容来源于网络,如有侵权,请联系作者删除!