Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Android notification putExtra() from Service
Forum Update on Monday, May 27th 2025

Android notification putExtra() from Service

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 281 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    adddeeee
    wrote on last edited by
    #1

    Hello!

    I would like to get some extra data passed along within my notification, triggered from within my foreground service.

    In the Service, I create an Intent and a PendingIntent. That works fine to trigger the notification. But I cannot seem to find a solution where I can pass extra information within the notification, to be opened when the user opens the app by clicking the notification.

    Intent notificationIntent = new Intent(m_instance, org.qtproject.qt5.android.bindings.QtActivity.class);
    PendingIntent pendingIntent = PendingIntent.getActivity(m_instance, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    

    I've tried adding:

    notificationIntent.putExtra("test", "testing");
    

    but I get NULL in my onCreate() method of the Service:

    public void onCreate() {
        super.onCreate();
        Log.i(TAG, "Creating Service");
        m_instance = QtAndroidService.this;
            
        Intent i = new Intent(m_instance, org.qtproject.qt5.android.bindings.QtActivity.class);
        
        String extra = intent.getExtras().getString("test");
    
    }
    

    What am I not understanding?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved