What is the package name in the RemoteViews constructor?
From the constructor documentationRemoteViews
-
public RemoteViews (String packageName, int layoutId)
The documentation states that packageName
- "The name of the package containing the layout resource".
- Why is this needed?
- Wouldn't say
layoutId
everything you need to know about the location of the layout resource? - What would you call the package name?
- Wasn't there always res-> layout?
source to share
Since Sirlate answered “Why is this necessary?” I will try to answer the rest of the questions.
Does
layoutId
n't it tell you everything you need to know about the location of the layout resource?
No, layoutId
like the ID of other resources, it is just a number. When you refer to it via R.layout.some_layout
, it actually refers to the identifier itself as a number.
Wasn't there always res-> layout?
Actually, no! You can put any resources in any folder (as long as inside /res
), even if it's a layout resource. /res/layout/
is just a handy folder as Android already identifies it first. At the end of the day, Android will simply refer to resources as an identification number.
What would you call the package name?
The package name of the app you want to use in the layout as specified by Sirlate.
Why is this needed?
In addition to Sirlate's answer, if you only have a resource ID, the OS won't be able to decide which package / app the layout is from.
source to share