473,387 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

what is push notification in android apps development? how to implement this?

127 100+
i am new to android apps development. what is push notification in android apps development and how to implement this?
May 29 '13 #1
12 4357
Nepomuk
3,112 Expert 2GB
Using push notifications basically means that the users device will somehow receive messages from a server which will result in a notification in the status bar - even if the app is not running itself. There are basically two ways of achieving this:
  1. Via SMS (text message). Here you will have to intercept the SMS and react to it in your app.
  2. Via a pulling service such as Google Cloud Messaging for Android. There are other similar services too (e.g. Urban Airship, PushWoosh, Deacon and Xtify) and they all have tutorials on their sites. So basically, decide which one you want to use and start with the tutorial to go with it.
May 29 '13 #2
impin
127 100+
can you give me any link with sample demo code. complete step by step demo... i tried Google Cloud Messaging for Android this but i get some error. GCM cannot reslove a type. not able to fix it.
Jun 10 '13 #3
Nepomuk
3,112 Expert 2GB
There are step by step instructions on the Getting Started with GCM site. Did you follow all of those steps? If you can't resolve GCM to a type, you may not have installed the Google Cloud Messaging for Android Library in the SDK Manager (under Extras). Also make sure, that everything that sounds reasonable in that list is installed.
Jun 10 '13 #4
impin
127 100+
i have installed Google Cloud Messaging for Android Library and Google Play services. but still i'am getting that error.

Expand|Select|Wrap|Line Numbers
  1.  public static final String EXTRA_MESSAGE = "message";
  2.  public static final String PROPERTY_REG_ID = "registration_id";
  3.  private static final String PROPERTY_APP_VERSION = "appVersion";
  4.  private static final String PROPERTY_ON_SERVER_EXPIRATION_TIME =
  5.          "onServerExpirationTimeMs";
  6.  public static final long REGISTRATION_EXPIRY_TIME_MS = 1000 * 3600 * 24 * 7;
  7.  String SENDER_ID = "40824748037";
  8.  static final String TAG = "GCMDemo";
  9.  TextView mDisplay;
  10.  GoogleCloudMessaging gcm;
  11.  AtomicInteger msgId = new AtomicInteger();
  12.  SharedPreferences prefs;
  13.  Context context;
  14.  
getting error in this line
Expand|Select|Wrap|Line Numbers
  1. GoogleCloudMessaging gcm;
Error: GoogleCloudMessaging cannot be resolved to a type
Jun 11 '13 #5
Nepomuk
3,112 Expert 2GB
Sounds like you haven't imported the class. Is there a line
Expand|Select|Wrap|Line Numbers
  1. import com.google.android.gms.gcm.GoogleCloudMessaging;
at the top with the other imports? If not, add it.
Jun 11 '13 #6
impin
127 100+
okay.
i added
Expand|Select|Wrap|Line Numbers
  1. import com.google.android.gms.gcm.GoogleCloudMessaging;
this. but i get error
Error: The import com.google cannot be resolved.

screenshot:

Jun 11 '13 #7
Nepomuk
3,112 Expert 2GB
So, it doesn't know the library. You'll have to add the Google Play Services SDK library to your project as described here under the heading Set Up a Project with the Library. The library you're looking for should be in <android-sdk>/extras/google/google_play_services/libproject/google-play-services_lib/ and is ideally copied into your projects classpath (as explained on the above website under Install the Google Play Services SDK, Point 4).
Jun 11 '13 #8
There are stepd of instructions on the Getting Started with GCM site. can you follow all of those steps? If you can't resolve GCM to a type, you may not have installed the Google Cloud Messaging for Android Library in the SDK Manager (under Extras). Also make sure, that everything that sounds reasonable in that list is installed.
there are also some other ways to do this job
Jun 11 '13 #9
impin
127 100+
I am using eclipse.
i have installed Google Cloud Messaging for Android Library and Google Play services in SDK manager.



"If you are using Eclipse, import the library project into your workspace. Click File > Import, select Android > Existing Android Code into Workspace, and browse to the copy of the library project to import it."

i don't get this. what i have to do?
Jun 11 '13 #10
impin
127 100+
i imported the google play services. but still i have that error.
how to add that to the workspace?

Jun 12 '13 #11
Nepomuk
3,112 Expert 2GB
In Eclipse, right click on the project you're working on (e.g. AndroidWebServices) and choose Properties. You want to modify the Java Build Path, so choose that. Then in the tab Projects add the lib project.
Jun 12 '13 #12
Old method of implementing push notification is depriciated now. So you need ot implement it using latest method i.e using google play service library. Learn complete android gcm tutorial for here.
What do you need to do?
Create a IntentService, one broadcast receiver to listen to announcement that the notification has arrived. Also you need one main activity to process the received json object as a notification.
Jan 17 '15 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Dave D | last post by:
What's the Big Java Development Environment These Days? I used to use VisualCafe years ago.... -- Dave
4
by: vbMark | last post by:
Here is what I have that is not working. For x = 1 To m_intNumberOfFields If m_oLabel(x).ParentOfComboBox = True Then Dim ctrl As clsComboBox Else Dim ctrl As clsTextBox End If
14
by: alainpoint | last post by:
Hello, I have the need to write the equivalent of Python class methods in C++. Chuck Allison proposes the following (http://www.artima.com/cppsource/simple.html): #include <iostream> using...
1
by: JJ | last post by:
I have a list of contacts in a webpage and the list is created throught the repeater controls. During ItemDataBound event of the repeater, I encrypt the ID of the contacts. When user double...
3
by: Michael Yanowitz | last post by:
Hello: I wrote the code below (much irrelevant code removed). This doesn't quite work. What I wanted it to do was a) Execute function ftimed, which takes a function and a timeout in seconds....
5
by: petru.marginean | last post by:
Hello, I would like to re-implement this function that currently uses pthreads: pthread_mutex_t mutex; int i = pthread_mutex_init(&mutex, 0); void MutexCB(int lock) {
6
by: olddocks | last post by:
what is the safe way to implement file upload in your server with PHP. Here is my situation.. 1. i want to let users upload small avatar like image files in the website. 2. I tried setting upload...
8
by: madeofdata | last post by:
what is the code to implement this function? countCharInText Counts the frequency of a character in a text the prototype is int countCharInText(char* text, int size, char toCount);
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.