3
votes

I'm trying to create a class diagram for an android project. I want my classes represent the activities, services and interfaces that I will implement.

There are several questions about it on the web, but I couldn't find a definitive answer.

I know that there aren't specific rules for Android and UML, but I have some doubts.

  • How can I represent the relationship between an Activity and a AsyncTask ?
  • How can I indicate that an Activity has an intent to another Activity ?

Maybe if someone has an example, will really help.

1
How about grabbing a good book about UML first before asking such really very basic question? - qwerty_so
How about help me since you wrote a comment? - G_comp
Well, now your questions sound more profound and I took back the down vote. Btw: I guess you mean Activity element rather than class. - qwerty_so
@ThomasKilian In this context, Activity is a class, isn't it? - sergej
@sergej Hmm. Activity diagram also have interruptible regions. So I would think that the mentioned activities are UML Activities. And one implements those Activities using Classes. Probably the OP should clarify this. - qwerty_so

1 Answers

8
votes

Maybe something like this?

enter image description here

  • MyBackgroundTask IS A AsyncTask
  • MyActivity IS A Activity
  • MyActivity HAS ONE MyBackgroundTask

You can use a dependency to show that there is an relationship between the AnActivity class and the AnotherActivity class:

enter image description here

In this case, it means that the AnActivity class requires the AnotherActivity class for its specification or implementation. Also, use notes to make it clear.

Update:

Another example:

  • MainActivity IS A FragmentActivity
  • MainActivity HAS SOME fragments. The fragments are of type String.

enter image description here