9

I'm starting my first Android app and after reading up I understand that the reverse domain name needed for an Android app is required in order to uniquely identify the app but is the application domain name used for anything other than uniquely identifying the app?

Specifically I am wondering about

1) The consequences (feature or bug?) of using different domain names for activities within the app

2) Is there any relation to a registered domain used for a website?

3) Any other snippets to fill in my lack of knowledge :)

jamesc
  • 12,423
  • 15
  • 74
  • 113

2 Answers2

14

Sun recomends that you use your company's Internet domain name (which is known to be unique) written in reverse. You then use subpackages for different projects. For example, horstmann.com is a domain that one of the authors registered. Written in reverse order, it turns into the package com.horstmann. That package can then be further subdivided into subpakcages such as com.horstmann.corejava.

From the Revised and Updated Java SE 6. Core Java.

This is the way all java packages are. Android is no different.

Jonathan Henson
  • 8,076
  • 3
  • 28
  • 52
  • Thank you, this explains a lot. So if I had mywebsite.com then I would call my android domain com.mywebsite.someapp. But what if I had activities (which require the reverse domain name as well) that had different domain names to the app domain name? Does this mean they won't work, may be shared? Sorry, just trying to understand this more clearly. – jamesc Jul 29 '11 at 21:05
  • It will work however you do it. The general idea however is to go from general to specific. So com.lionfront.xml would be my xml library. com.lionfront.xml.flytoTheMoon would be my xml lib that flies ships to the moon. I would just add my activity to the end of my reverse domain stuff. Anyways, if you choose to name them differently, it will still work it just won't follow convention. You just want to ensure uniqueness. – Jonathan Henson Jul 29 '11 at 21:08
  • 1
    @jamesw sorry forgot to ping. Traditionally, you want your activities to be inside the same package as your application so as a best practice, I would just put them in the same domain as your main app. Anyhow, you don't have to do that. – Jonathan Henson Jul 29 '11 at 21:10
  • Thank you. Does it matter how deep you go with the sub domains? I'm thinking com.mydomain.mobile.category.appname to enable me to categories my mobile apps. Would this be bad practice? p.s. How do I ping you? – jamesc Jul 29 '11 at 22:29
  • @name is how you ping. No, it doesn't matter. – Jonathan Henson Jul 30 '11 at 04:14
4

Sorry if this does't answer all your questions but i think that the answer is more a general java question then an android specific question. This is a pretty good explanation

Community
  • 1
  • 1
pocorschi
  • 3,605
  • 5
  • 26
  • 35