Search code examples
androidandroid-appwidgetandroid-remoteview

What is package name in the RemoteViews constructor?


From the documentation, the constructor of RemoteViews is

public RemoteViews (String packageName, int layoutId)

The documentation says that packageName is "Name of the package that contains the layout resource".

  • Why is this needed?
  • Wouldn't the layoutId tell you everything that you need to know about the location of the layout resource?
  • What would you put as the package name?
  • Wouldn't it always be res->layout?

Solution

  • In case you have multiple widget and app and you signed them all with the same key (Signing the applications with the same key allows them access to each other's data.), then you may have access to them too which does not have the same package name.