Search code examples
androidhtmlcounter

Counter app how to? for notification to Android app


I want to make a html website. And every time someone downloads something off my site, I want to get a notification on my phone. I have very little knowledge in Android app making but I do have some in html. Is there a way to do this? And where can I learn to do this? Which programming language? Thank you for the answers! I will start working on it.


Solution

  • Website part

    Here you will need a server-side script language like ASP.NET or PHP to build your website where it will have some code to handle the part of capturing the click on the linked item you are showing on the site, getting its information like its name and then pushing a message to Google cloud messaging (GCM). You need to register with GCM to obtain Sender ID to use to it publish your message from your website's server-side code.

    Well, this is quite a large topic, I will list down some useful resources to get you started with the development in website

    ASP.NET Tutorial

    PHP Tutorial

    Google Cloud Messaging

    Android part

    Here you want to create a simple app, that has a service that subscribes to GCM (using the same GCM sender id) to obtain registration token and then it will be able to read the push notification messages sent from GCM via the onMessageReceived Method

    @Override
      public void onMessageReceived(String from, Bundle data) {
         String message = data.getString("message");
         Log.d(TAG, "From: " + from);
         Log.d(TAG, "Message: " + message);
         // Handle received message here.
      }
    

    Some useful resources for android and GCM:

    Android tutorial

    Android GCM

    GCM Push notifications