本文整理匯總了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();
}
}