Android Question Class or Activity, what is better?

Discussion in 'Android Questions' started by mark35at, Jan 23, 2015.

  1. mark35at

    mark35at Well-Known Member Licensed User

    Maybe a silly question but ...

    One app with two activities. The first does lots of things, one of which is taking a screenshot, saving to a file and passing the filename to activity 2. Activity 2 processes the bitmap intensively and returns a list to the first activity.

    My question, would activity 2 be better as a class. What benefit would I get from a class?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Does each activity handle a different screen? If yes then two activities sounds like a good solution.
     
  3. mark35at

    mark35at Well-Known Member Licensed User

    Yes, the first activity generates the screenshot and the second activity analyses this screenshot and returns data to the first activity which then updates its screen. The second activity is only normally needed once.

    I just wondered if there would be any benefit (speed or comfort) from using a class instead of the second activity,as it it really does is maths.

    A footnote. When the app is working correctly, the second activity will not even show a screen, just a progress dialog will be shown from activity 1. At present I am showing the calculations on screen for debugging.
     
  4. DonManfred

    DonManfred Expert Licensed User

    Then maybe a service could be good to do that calculations.
    From the service you can raise subs in your main which then updates the ui (progress)
     
    lemonisdead likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice