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

  • Home
  • SEARCH
  • 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 8998897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:06:06+00:00 2026-06-16T00:06:06+00:00

I’m following this guide but I’ve remade it a bit; removed the first activity

  • 0

I’m following this guide but I’ve remade it a bit;
removed the first activity with all the email and name stuff. Basicly, what Ive done is:
an app with a button and a textview and when you press the button the regId pops up. So far so good, but when it comes to receiving the push itself there’s no popup, no wake lock or anything, just a simple row in the “notification center” (dont really know what its called on android). heres the code:

private static void generateNotification(Context context, String message) 
    {
        int icon = R.drawable.ic_launcher;
        long when = System.currentTimeMillis();
        NotificationManager notificationManager = (NotificationManager)
                context.getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notification = new Notification(icon, message, when);

        String title = context.getString(R.string.app_name);

        Intent notificationIntent = new Intent(context, MainActivity.class);
        // set intent so it does not start a new activity
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
                Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent intent =
                PendingIntent.getActivity(context, 0, notificationIntent, 0);
        notification.setLatestEventInfo(context, title, message, intent);
        notification.flags |= Notification.FLAG_AUTO_CANCEL;

Errors:
Notification notification = new Notification(icon, message, when);

The constructor Notification(int, charSequence, long) is deprecated

notification.setLatestEventInfo(context, title, message, intent);
The method setLatestEventInfo(Context, CharSequence, CharSequence, PendingIntent) from the type Notification is deprecated

(the logCat comes out clean from errors)

when I open the declaration it says “The JAR file has no source attachment”.
I’ve tried to add sources and googleing. but whatever i do it says

the source attachment does not contain the source for the file Notification.class

I believe that my problem with getting the message in the push is because of this. any ideas on how to fix it?

PS. I’m new to all this, please let me know if you need more of the code AND do tell me if I’m on the wrong track here!:)

  • 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-16T00:06:06+00:00Added an answer on June 16, 2026 at 12:06 am

    This has nothing to do with your warning. The warning just says, that the method that you are using is deprecated since API level 11. For newer APIs you can(but you don’t have to, it’s just recommended) use Notification.Builder:

    Notification noti = new Notification.Builder(mContext)
         .setContentTitle("New mail from " + sender.toString())
         .setContentText(subject)
         .setSmallIcon(R.drawable.new_mail)
         .setLargeIcon(aBitmap)
         .build();
    

    Edit:
    checking for current API:

    int currentVersion = android.os.Build.VERSION.SDK_INT;
    int honeycombVersion = android.os.Build.VERSION_CODES.HONEYCOMB;
    
    if (currentVersion >= honeycombVersion ){
        // Use Notification.Builder
    } else{
        // Use Notification(int, charSequence, long)
    }
    

    Edit2:
    You can use the Notification.Builder on lower APIs if you use the support lib.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
Let's say I'm outputting a post title and in our database, it's Hello Y’all
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into

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.