Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Android
  4. Application Architecture

Application Architecture

Scheduled Pinned Locked Moved Android
csharpandroiddesignarchitecturehelp
13 Posts 5 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ericgahn
    wrote on last edited by
    #1

    Hi all; I must start this discussion with three statements. (a) I am one of those who learns by doing (b) I have a basic understanding of Android programming (c) I am a .NET developer (ie: I know how to program). What I seek is advise on how to go about developing an application I have in mind. This application will be running in the background (therefore a Service) periodically polling a URL to check for new messages. If a new message is found, a notification or toast is displayed. So far, so good. I think I know how to do all that. The service will start automatically at device boot up. This, I think, I have also found how to do. The problem I have is that as part of the same application I want a UI which the user can then use to process the received message/s. How do I go about implementing this within the same app. The aim is to have ONE installation package. I do not think what I seek is rocket science. I would appreciate any notes or links to relevant guides or tutorials. Regards Eric

    L D 2 Replies Last reply
    0
    • E ericgahn

      Hi all; I must start this discussion with three statements. (a) I am one of those who learns by doing (b) I have a basic understanding of Android programming (c) I am a .NET developer (ie: I know how to program). What I seek is advise on how to go about developing an application I have in mind. This application will be running in the background (therefore a Service) periodically polling a URL to check for new messages. If a new message is found, a notification or toast is displayed. So far, so good. I think I know how to do all that. The service will start automatically at device boot up. This, I think, I have also found how to do. The problem I have is that as part of the same application I want a UI which the user can then use to process the received message/s. How do I go about implementing this within the same app. The aim is to have ONE installation package. I do not think what I seek is rocket science. I would appreciate any notes or links to relevant guides or tutorials. Regards Eric

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Lots of excellent tutorials at http://www.codeproject.com/KB/android/#Android+Tutorial+Contest[^].

      E 1 Reply Last reply
      0
      • E ericgahn

        Hi all; I must start this discussion with three statements. (a) I am one of those who learns by doing (b) I have a basic understanding of Android programming (c) I am a .NET developer (ie: I know how to program). What I seek is advise on how to go about developing an application I have in mind. This application will be running in the background (therefore a Service) periodically polling a URL to check for new messages. If a new message is found, a notification or toast is displayed. So far, so good. I think I know how to do all that. The service will start automatically at device boot up. This, I think, I have also found how to do. The problem I have is that as part of the same application I want a UI which the user can then use to process the received message/s. How do I go about implementing this within the same app. The aim is to have ONE installation package. I do not think what I seek is rocket science. I would appreciate any notes or links to relevant guides or tutorials. Regards Eric

        D Offline
        D Offline
        Dominic Burford
        wrote on last edited by
        #3

        I'm not entirely clear what your question relates to. Are you asking how to build the UI or how to process the received messages? Can you clarify what you need help with. What are you trying to achieve?

        "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare

        E 1 Reply Last reply
        0
        • L Lost User

          Lots of excellent tutorials at http://www.codeproject.com/KB/android/#Android+Tutorial+Contest[^].

          E Offline
          E Offline
          ericgahn
          wrote on last edited by
          #4

          Thanks for this

          1 Reply Last reply
          0
          • D Dominic Burford

            I'm not entirely clear what your question relates to. Are you asking how to build the UI or how to process the received messages? Can you clarify what you need help with. What are you trying to achieve?

            "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare

            E Offline
            E Offline
            ericgahn
            wrote on last edited by
            #5

            Hi Dominic; What I need to know is how to build ONE application that starts automatically as a service, but has a UI which the user will use when the service raises a notification. Which activity will have broadcast, be a broadcast receiver, etc.... Thanks Eric

            G D 2 Replies Last reply
            0
            • E ericgahn

              Hi Dominic; What I need to know is how to build ONE application that starts automatically as a service, but has a UI which the user will use when the service raises a notification. Which activity will have broadcast, be a broadcast receiver, etc.... Thanks Eric

              G Offline
              G Offline
              gupta avinash
              wrote on last edited by
              #6

              Create an Android Application project, register a Broadcast Receiver with action android.intent.action.BOOT_COMPLETED in the Manifest file.

              <receiver android:name=".MyReceiver" >
              <intent-filter>
              <action android:name="android.intent.action.BOOT_COMPLETED" />
              </intent-filter>
              </receiver>

              Then start the Service from the onReceive() method of the Broadcast Receiver.

              public class MyReceiver extends BroadcastReceiver {

              @Override
              public void onReceive(Context context, Intent intent) {		
                  	Intent i = new Intent(context, MyService.class); 
                  	context.startService(i);         
              }
              

              }

              Create an Activity with the desired UI and pass that Activity as Pending Intent to the notification.

              Intent intent = new Intent(this, MyActivity.class);
              PendingIntent launchIntent = PendingIntent.getActivity(context, 0, intent, 0);

              When the user taps on the Notification, the Activity used to create the PendingIntent is started. P.S. - You can have Service, BroadcastReceiver and Activities all in one project.

              1 Reply Last reply
              0
              • E ericgahn

                Hi Dominic; What I need to know is how to build ONE application that starts automatically as a service, but has a UI which the user will use when the service raises a notification. Which activity will have broadcast, be a broadcast receiver, etc.... Thanks Eric

                D Offline
                D Offline
                Dominic Burford
                wrote on last edited by
                #7

                I've done something similar that may give you some ideas. The application I worked on previously polled for updates from a web service. The class that did this background polling was based on the Service class. When a data update was detected from the web service, it would populate the database with the new data. Do you know what your trigger is? You mentioned that you are polling a URL? Are you polling a web service for updates then? How do you know when you need to trigger your UI?

                "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare

                E 1 Reply Last reply
                0
                • D Dominic Burford

                  I've done something similar that may give you some ideas. The application I worked on previously polled for updates from a web service. The class that did this background polling was based on the Service class. When a data update was detected from the web service, it would populate the database with the new data. Do you know what your trigger is? You mentioned that you are polling a URL? Are you polling a web service for updates then? How do you know when you need to trigger your UI?

                  "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare

                  E Offline
                  E Offline
                  ericgahn
                  wrote on last edited by
                  #8

                  Hi; The trigger will be a field in the data received from the webservice. When a trigger is received, a notification/toast will be displayed and then it is up to the user when to open the UI to check the full details what was received. Like the GMail app: you are notified when an email is received but you decide when to open the app to read the email. That part I have it sorted and planned and is something I had implemented on Windows Mobile (in another life). What I need to know are the steps (and Objects to inherit from) required to do it in Android. My mind is not yet clear about the intents/broadcasts/etc.... Thanks again. Eric

                  D 1 Reply Last reply
                  0
                  • E ericgahn

                    Hi; The trigger will be a field in the data received from the webservice. When a trigger is received, a notification/toast will be displayed and then it is up to the user when to open the UI to check the full details what was received. Like the GMail app: you are notified when an email is received but you decide when to open the app to read the email. That part I have it sorted and planned and is something I had implemented on Windows Mobile (in another life). What I need to know are the steps (and Objects to inherit from) required to do it in Android. My mind is not yet clear about the intents/broadcasts/etc.... Thanks again. Eric

                    D Offline
                    D Offline
                    Dominic Burford
                    wrote on last edited by
                    #9

                    Presumably then when the user sees that they have a new notification, they open your app to view the details. So it should just be a case of invoking your UI and displaying the most recent notification. Maybe you could add a flag so you know which notifications have been opened / read, and highlight those in some way. I'm not sure what data you are displaying, but maybe you could display your data in a grid format, in which case you'd need to define an Adapter. I wrote an article about Android adapters that you may find useful Displaying Data with an Adapter in Xamarin.Android and Visual Studio[^]

                    "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare

                    E 1 Reply Last reply
                    0
                    • D Dominic Burford

                      Presumably then when the user sees that they have a new notification, they open your app to view the details. So it should just be a case of invoking your UI and displaying the most recent notification. Maybe you could add a flag so you know which notifications have been opened / read, and highlight those in some way. I'm not sure what data you are displaying, but maybe you could display your data in a grid format, in which case you'd need to define an Adapter. I wrote an article about Android adapters that you may find useful Displaying Data with an Adapter in Xamarin.Android and Visual Studio[^]

                      "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare

                      E Offline
                      E Offline
                      ericgahn
                      wrote on last edited by
                      #10

                      Hi Dominc That is Xamarin. I am trying to keep to Java and basic Android for now. Thanks Eric

                      D D 2 Replies Last reply
                      0
                      • E ericgahn

                        Hi Dominc That is Xamarin. I am trying to keep to Java and basic Android for now. Thanks Eric

                        D Offline
                        D Offline
                        Dominic Burford
                        wrote on last edited by
                        #11

                        I know you are using Java but the classes / objects are the same. Only the syntax is different, but Java and C# are similar enough that you should be able to leverage my example code into your own application.

                        "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare

                        E 1 Reply Last reply
                        0
                        • E ericgahn

                          Hi Dominc That is Xamarin. I am trying to keep to Java and basic Android for now. Thanks Eric

                          D Offline
                          D Offline
                          dr samuel john
                          wrote on last edited by
                          #12

                          I think you already have an answer here - read the one posted by gupta.avinash or refer to the article - Article 10 - Beginner's Guide to Android Services[^]

                          1 Reply Last reply
                          0
                          • D Dominic Burford

                            I know you are using Java but the classes / objects are the same. Only the syntax is different, but Java and C# are similar enough that you should be able to leverage my example code into your own application.

                            "There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult." - C.A.R. Hoare

                            E Offline
                            E Offline
                            ericgahn
                            wrote on last edited by
                            #13

                            Ah! Then I must say thank you. Eric

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups