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] How do I run the app's activity?
Forum Updated to NodeBB v4.3 + New Features

[android] How do I run the app's activity?

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
android serviceandroidqt
1 Posts 1 Posters 316 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.
  • B Offline
    B Offline
    bipll
    wrote on 13 Jul 2022, 14:38 last edited by
    #1

    In my application, I start a foreground service which is a custom service that runs in a separate process, same .so:

    public class MyService extends QtService {
    @Override
        public int onStartCommand(Intent intent, int flags, int startId) {
            createNotificationChannel();
            // This should be a different .class, correct?
            Intent notificationIntent = new Intent(this, MyService.class);
            PendingIntent pendingIntent =
                    PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE);
    
            notification = new NotificationCompat.Builder(this, CHANNEL_ID)
                .setContentTitle("Title")
                .setContentText("Text")
                .setSmallIcon(R.drawable.notification)
                .setContentIntent(pendingIntent)
                .setTicker("Running")
                .setOngoing(true)
                .setPriority(NotificationCompat.PRIORITY_LOW)
                .build();
    
            // Notification ID cannot be 0.
            startForeground(ONGOING_NOTIFICATION_ID, notification);
            return START_STICKY;
        }
    
    

    Consequently, I'd love this event to raise to the foreground the main activity itself when tapped. My understanding is that I need to pass its .class to the Intent constructor, but I couldn't figure out which one. The app itself is written in C++/QML and I needed no special reason to define a custom Activity subclass, but the default name from AndroidManifest.xml is org.qt.....QtActivity which does not look very specific.

    Do I miss something? Or do I need to subclass Activity after all? Could anyone please help?

    1 Reply Last reply
    0

    1/1

    13 Jul 2022, 14:38

    • Login

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