本文整理汇总了Java中android.app.Activity.getCallingActivity方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.getCallingActivity方法的具体用法?Java Activity.getCallingActivity怎么用?Java Activity.getCallingActivity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Activity
的用法示例。
在下文中一共展示了Activity.getCallingActivity方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractCallerAuthDomains
import android.app.Activity; //导入方法依赖的package包/类
/**
* Extracts the set of authentication domains for the caller of the provided activity.
*/
@NonNull
public static Set<AuthenticationDomain> extractCallerAuthDomains(@NonNull Activity activity) {
ComponentName callingActivity = activity.getCallingActivity();
if (callingActivity == null) {
return Collections.emptySet();
}
String callingPackage = callingActivity.getPackageName();
AuthenticationDomain authenticationDomain =
AuthenticationDomain.fromPackageName(activity, callingPackage);
if (null == authenticationDomain) {
return Collections.EMPTY_SET;
}
return new HashSet<>(Arrays.asList(authenticationDomain));
}
示例2: initializeCallingPackage
import android.app.Activity; //导入方法依赖的package包/类
private void initializeCallingPackage(final Activity activity) {
ComponentName componentName = activity.getCallingActivity();
if (componentName == null) {
return;
}
callingPackage = componentName.getPackageName();
}
示例3: getCallingActivity
import android.app.Activity; //导入方法依赖的package包/类
public static ComponentName getCallingActivity(Activity calledActivity) {
ComponentName result = calledActivity.getCallingActivity();
if (result == null) {
return (ComponentName) calledActivity.getIntent().getParcelableExtra(EXTRA_CALLING_ACTIVITY);
}
return result;
}
示例4: setSourceApplication
import android.app.Activity; //导入方法依赖的package包/类
/**
* Source Application setters and getters
*/
private static void setSourceApplication(Activity activity) {
ComponentName callingApplication = activity.getCallingActivity();
if (callingApplication != null) {
String callingApplicationPackage = callingApplication.getPackageName();
if (callingApplicationPackage.equals(activity.getPackageName())) {
// open by own app.
resetSourceApplication();
return;
}
sourceApplication = callingApplicationPackage;
}
// Tap icon to open an app will still get the old intent if the activity was opened by an
// intent before. Introduce an extra field in the intent to force clear the
// sourceApplication.
Intent openIntent = activity.getIntent();
if (openIntent == null ||
openIntent.getBooleanExtra(SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT, false)) {
resetSourceApplication();
return;
}
Bundle applinkData = AppLinks.getAppLinkData(openIntent);
if (applinkData == null) {
resetSourceApplication();
return;
}
isOpenedByApplink = true;
Bundle applinkReferrerData = applinkData.getBundle("referer_app_link");
if (applinkReferrerData == null) {
sourceApplication = null;
return;
}
String applinkReferrerPackage = applinkReferrerData.getString("package");
sourceApplication = applinkReferrerPackage;
// Mark this intent has been used to avoid use this intent again and again.
openIntent.putExtra(SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT, true);
return;
}
示例5: initializeCallingPackage
import android.app.Activity; //导入方法依赖的package包/类
private void initializeCallingPackage(Activity activity) {
ComponentName componentName = activity.getCallingActivity();
if (componentName != null) {
this.callingPackage = componentName.getPackageName();
}
}