Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7870671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:41:05+00:00 2026-06-03T01:41:05+00:00

I am a huge noob to Android programming so sorry if this is a

  • 0

I am a huge noob to Android programming so sorry if this is a simple task. I pretty much followed the Vogella push notification tutorial for push notifications (http://www.vogella.com/articles/AndroidCloudToDeviceMessaging/article.html). I’ve read some other stack overflow questions but I’m a little confused on how to open a intent once I receive the notification.

For example, if I just wanted the notification to lead me to a website, how would that work? Would it have to go under my MessageReceivedActivity or another project/class all together?

Thanks

Here is the code I have for my C2DMMessageReceiver

@Override
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();
    Log.w("C2DM", "Message Receiver called");
    if ("com.google.android.c2dm.intent.RECEIVE".equals(action)) {
        Log.w("C2DM", "Received message");
        final String payload = intent.getStringExtra("payload");
        Log.d("C2DM", "dmControl: payload = " + payload);
        // TODO Send this to my application server to get the real data
        // Lets make something visible to show that we received the message
        createNotification(context, payload);

    }
}

public void createNotification(Context context, String payload) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = new Notification(R.drawable.ic_launcher,
            "Message received", System.currentTimeMillis());
    // Hide the notification after its selected
    notification.flags |= Notification.FLAG_AUTO_CANCEL;

    //adding LED lights to notification
    notification.defaults |= Notification.DEFAULT_LIGHTS;

    Intent intent = new Intent(context, MessageReceivedActivity.class);
    intent.putExtra("payload", payload);

    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
            intent, 0);
    notification.setLatestEventInfo(context, "Message",
            "New message received", pendingIntent);
    notificationManager.notify(0, notification);

}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:41:06+00:00Added an answer on June 3, 2026 at 1:41 am

    if you want to open a website on notification click try this:

        public void createNotification(Context context, String payload) {
            NotificationManager notificationManager = (NotificationManager) context
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            Notification notification = new Notification(R.drawable.ic_launcher,
                    "Message received", System.currentTimeMillis());
            // Hide the notification after its selected
            notification.flags |= Notification.FLAG_AUTO_CANCEL;
    
            //adding LED lights to notification
            notification.defaults |= Notification.DEFAULT_LIGHTS;
    
            Intent intent = new Intent("android.intent.action.VIEW", 
             Uri.parse("http://my.example.com/"));
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
                    intent, 0);
            notification.setLatestEventInfo(context, "Message",
                    "New message received", pendingIntent);
            notificationManager.notify(0, notification);
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry if this is a stupid noob question. I'm doing a very small project
I am sure this is so easy and I'm just a huge huge noob.
I'm a huge erlang noob, and while compiling ejabberd, I get this error: make[1]:
I had a huge file for creating this GUI and I have shortened it
please forgive me if this is a noob question, but i'm a beginner at
I have this huge data frame that has servernames, Date, CPU, memory as the
huge = sum([x for key in G for (_,x) in G[key]]+1) This is what
Let me start off by saying I'm a huge Git (and Ubuntu) noob. I
Huge database in mssql2005 with big codebase depending on the structure of this database.
Hi i am tearing my hair out at this one, i am a noob

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.