Issue
I am developing two android applications, one being the baseApp and other serving as a pluginApp. The aim is to extend the functionality of the baseApp when its corresponding plugin is installed. The pluginApp will contain XML layout files which will contain 'new_layouts' which I need to display in the baseApp. Is there a way to pass the new_layout to the baseApp from pluginApp via Inter Process Communication or something similar?
I tried below approach with no luck I wrapped the layout file from pluginApp as a 'RemoteViews' object and passed it to the baseApp, but when I inflate it into baseApp I get an error saying
android.view.InflateException: Binary XML file line #9: Class not allowed to be inflated android.widget.EditText
Note: The 'new_layout' contains an EditText among other elements with EditText being the first child.
I have never used RemoteViews before and don't understand their purpose yet.
Please guide me on 1. whether Using view from one app into other app is possible? 2. Can RemoteViews be used for this purpose? If yes then how? 3. Why am I getting the error and what does that indicate?
Solution
- whether Using view from one app into other app is possible?
Not directly.
- Can RemoteViews be used for this purpose?
Yes.
- Why am I getting the error
Because EditText
is not one of the few widgets supported by RemoteViews
.
what does that indicate?
It indicates that you have three choices:
Limit yourself to the widgets supported by
RemoteViews
Do not try to share UI between apps
Implement your own
RemoteViews
-like system
In the end, a RemoteViews
is merely a data structure that describes how to build a UI and how to send back very coarse-grained events (e.g., clicks, via a PendingIntent
). There is nothing, other than time and expertise, stopping you from creating your own Parcelable
data structure that describes how to build a richer UI than RemoteViews
supports.
Answered By - CommonsWare
Answer Checked By - Candace Johnson (JavaFixing Volunteer)