Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to define started activity when relaunching Android application?
    primarykey
    data
    text
    <p>I am fairly new to Android, and am currently working on a simple XMPP Client. A user should be able to log in, and should be notified whenever an XMPP message arrives. It should be possible to access an overview of all messages that arrived during the current session.</p> <p>When launching the application, a LoginActivity is started, prompting the user to fill in his or her credentials. If the right credentials are provided, a background service is started:</p> <pre><code>Intent intent = new Intent(this, NotificationService.class); startService(intent); </code></pre> <p>On startup, the notification service adds a packet listener to the XMPP connection and requests to be running in the foreground. The users is prompted with a notification caused by this foreground request ("Ongoing"). Now I have provided a second activity called XMPPClientActivity, showing all messages that are received during the session and a simple logout button. When opening the application from within the "Ongoing" notification, the XMPPClientActivity is started because the notification is defined like this:</p> <pre><code>xmppIntent = new Intent(this, XMPPClientActivity.class); pendingIntent = PendingIntent.getActivity(this, 0, xmppIntent, 0); NotificationCompat.Builder xmppBuilder = new NotificationCompat.Builder(this); xmppBuilder.setContentIntent(pendingIntent); // Notification details startForeground(id, xmppBuilder.build()); </code></pre> <p>When opening the application from the home screen however, the LoginActivity is opened again. Of course I want the XMPPActivity to be started, but I can't seem to figure out how this should be done. I have been looking into binding an activity to a service, but I'm unsure if this can be of any help. What is the right way to do this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload