RemoteViews can be used across processes, but there is no restriction on the access of resources across processes. RemoteViews source code is as follows:

public RemoteViews(String packageName, int layoutId) { this(getApplicationInfo(packageName, UserHandle.myUserId()), layoutId); } protected RemoteViews(ApplicationInfo application, int layoutId) { mApplication = application; . }Copy the code

When RemoteViews is instantiated, it holds an mApplication variable that can be used to access resources across processes.

/** @hide */
public View apply(Context context, ViewGroup parent, OnClickHandler handler) {
    ...
    final Context contextForResources = getContextForResources(context);
    Context inflationContext = new ContextWrapper(context) {
        @Override
        public Resources getResources() {
            return contextForResources.getResources();
        }
        @Override
        public Resources.Theme getTheme() {
            return contextForResources.getTheme();
        }
        @Override
        public String getPackageName() {
            returncontextForResources.getPackageName(); }}; LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); . } private Context getContextForResources(Context context) {if(mApplication ! = null) {if (context.getUserId() == UserHandle.getUserId(mApplication.uid)
                && context.getPackageName().equals(mApplication.packageName)) {
            return context;
        }
        try {
            return context.createApplicationContext(mApplication,
                    Context.CONTEXT_RESTRICTED);
        } catch (NameNotFoundException e) {
            Log.e(LOG_TAG, "Package name " + mApplication.packageName + " not found"); }}return context;
}
Copy the code

Thank you for the feedback [email protected], I hope to help you.