469,326 Members | 1,500 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

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 4109
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

Post your reply

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

Similar topics

4 posts views Thread by vbMark | last post: by
14 posts views Thread by alainpoint | last post: by
3 posts views Thread by Michael Yanowitz | last post: by
5 posts views Thread by petru.marginean | last post: by
8 posts views Thread by madeofdata | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.