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 8706525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:38:07+00:00 2026-06-13T03:38:07+00:00

Okay, here is my problem. I have a Service that receives Push notifications. Now,

  • 0

Okay, here is my problem. I have a Service that receives Push notifications. Now, depending on the content of the push notification it should start the corresponding application, if clicked on it.

I got no problem receiving the push notifications or using the service, the only thing I can’t get to work, is the part where it has the open the right application.

What do I need to do, to open an application from a Service? This has to be dynamically, since there will be multiple apps working with this service.

It would be great if anyone could point me into the right direction.

PS. I am using GCM service, which I put into a library, so I can use it in multiple apps of mine. This is the GCMIntentService.onMessage() function in which I need to check the content of the url and then set the right intent for the notification:

@Override
protected void onMessage(Context arg0, Intent arg1)
{
    Log.i(TAG, "new message = " + arg1.getExtras());

    //Get a reference to the NotificationManager
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager mNotificationManager = (NotificationManager) getSystemService(ns);

    //Instantiate the Notification      
    int icon = getResourseIdByName(arg0.getApplicationContext().getPackageName(), "drawable", "notification_icon");
    CharSequence tickerText = arg1.getExtras().getString("tickertext");
    long when = System.currentTimeMillis();

    Notification notification = new Notification(icon, tickerText, when);

    //Define the notification's message and PendingIntent 
    Context context = getApplicationContext();
    CharSequence contentTitle = arg1.getExtras().getString("contentTitle");
    CharSequence contentText = arg1.getExtras().getString("contentText");

    Intent notificationIntent = null;

    if(arg1.getExtras().getString("url").isEmpty())
    {
        notificationIntent = new Intent(this, arg1.getExtras().getString("packageName").getClass());
    }
    else
    {
        notificationIntent = new Intent(this, MyWebView.class);
    }

    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK);

    notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
    notification.flags = Notification.FLAG_AUTO_CANCEL;

    //Pass the Notification to the NotificationManager
    int notificationId = Integer.parseInt(arg1.getExtras().getString("notificationId"));

    mNotificationManager.notify(notificationId, 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-13T03:38:08+00:00Added an answer on June 13, 2026 at 3:38 am

    Applications can be launched using Intents. You need to construct correct PendingIntent object, like this:

    Intent targetIntent = new Intent(Intent.ACTION_MAIN, null);
    targetIntent.addCategory(Intent.CATEGORY_LAUNCHER);
    ComponentName cn = new ComponentName("target_app_package_name", "target_activity_class_name");
    targetIntent.setComponent(cn);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0, targetIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
    

    If you didn’t know target package or target Activity, you can use following code:

    Intent startingIntent = context.getPackageManager().getLaunchIntentForPackage("target_app_package_name");
    context.startActivity(startingIntent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, here is my problem: I have a form that requires to have two
Okay here is the problem, I have images of different sizes, but that doesn't
Okay, so here's my problem: I have a list of members on a website,
I have a problem with (for me to complicated) MySql query. Okay, here is
Okay here is what I'm trying to do: I have a model object that
Okay so here's, the scenario I have a thumbnail that contains an artists profile
Okay so here's my problem. I have a two global NSString variables. globalVariable1 //stores
Okay so here is the problem I am having. I have several unit tests
Okay... So, I came across the following problem: I have one table that works
Okay, so, here's my problem: I have developed a .NET 4.0 (Client Profile) +

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.