Java Code Examples for android.app.ActivityThread#currentApplication()

The following examples show how to use android.app.ActivityThread#currentApplication() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnimatorSet.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public AnimatorSet() {
    super();
    mNodeMap.put(mDelayAnim, mRootNode);
    mNodes.add(mRootNode);
    boolean isPreO;
    // Set the flag to ignore calling end() without start() for pre-N releases
    Application app = ActivityThread.currentApplication();
    if (app == null || app.getApplicationInfo() == null) {
        mShouldIgnoreEndWithoutStart = true;
        isPreO = true;
    } else {
        if (app.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.N) {
            mShouldIgnoreEndWithoutStart = true;
        } else {
            mShouldIgnoreEndWithoutStart = false;
        }

        isPreO = app.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.O;
    }
    mShouldResetValuesAtStart = !isPreO;
    mEndCanBeCalled = !isPreO;
}
 
Example 2
Source File: RemoteViews.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private static ApplicationInfo getApplicationInfo(String packageName, int userId) {
    if (packageName == null) {
        return null;
    }

    // Get the application for the passed in package and user.
    Application application = ActivityThread.currentApplication();
    if (application == null) {
        throw new IllegalStateException("Cannot create remote views out of an aplication.");
    }

    ApplicationInfo applicationInfo = application.getApplicationInfo();
    if (UserHandle.getUserId(applicationInfo.uid) != userId
            || !applicationInfo.packageName.equals(packageName)) {
        try {
            Context context = application.getBaseContext().createPackageContextAsUser(
                    packageName, 0, new UserHandle(userId));
            applicationInfo = context.getApplicationInfo();
        } catch (NameNotFoundException nnfe) {
            throw new IllegalArgumentException("No such package " + packageName);
        }
    }

    return applicationInfo;
}
 
Example 3
Source File: PluginManager.java    From VirtualAPK with Apache License 2.0 6 votes vote down vote up
protected PluginManager(Context context) {
    if (context instanceof Application) {
        this.mApplication = (Application) context;
        this.mContext = mApplication.getBaseContext();
    } else {
        final Context app = context.getApplicationContext();
        if (app == null) {
            this.mContext = context;
            this.mApplication = ActivityThread.currentApplication();
        } else {
            this.mApplication = (Application) app;
            this.mContext = mApplication.getBaseContext();
        }
    }
    
    mComponentsHandler = createComponentsHandler();
    hookCurrentProcess();
}
 
Example 4
Source File: ContentResolver.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/** {@hide} */
public ContentResolver(@Nullable Context context, @Nullable ContentInterface wrapped) {
    mContext = context != null ? context : ActivityThread.currentApplication();
    mPackageName = mContext.getOpPackageName();
    mTargetSdkVersion = mContext.getApplicationInfo().targetSdkVersion;
    mWrapped = wrapped;
}
 
Example 5
Source File: ContentResolver.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
public ContentResolver(Context context) {
    mContext = context != null ? context : ActivityThread.currentApplication();
    mPackageName = mContext.getOpPackageName();
    mTargetSdkVersion = mContext.getApplicationInfo().targetSdkVersion;
}
 
Example 6
Source File: WebViewDelegate.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the application which is embedding the WebView.
 */
public Application getApplication() {
    return ActivityThread.currentApplication();
}
 
Example 7
Source File: ContentResolver.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public ContentResolver(Context context) {
    mContext = context != null ? context : ActivityThread.currentApplication();
    mPackageName = mContext.getOpPackageName();
    mTargetSdkVersion = mContext.getApplicationInfo().targetSdkVersion;
}