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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:30:07+00:00 2026-05-21T17:30:07+00:00

I’m writing Media files share application. Now it is divided into 2 parts: <application>

  • 0

I’m writing Media files share application.

Now it is divided into 2 parts:

<application>
        <activity android:name="FileUploader"
                  android:label="..."
                  >
            <intent-filter>
                <action android:name="android.intent.action.SEND"/>
                <data android:mimeType="*/*"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>

    <service android:name=".FileUploaderService" />


    </application>

FileUploader is an activity which should be launched from other activities (eg. Gallery or Camera).
FileUploaderService is a service, which actually uploads file to HTTP server. It executes several HTTP requests.

Now it is possible that user press Home button during uploading and returns to Home screen.
In this case I want to have a notification with current upload stage details which will return user to Activity when tapped.

I’m creatung it like this:

    int icon = R.drawable.icon;
    CharSequence tickerText = "Uploading File";
    long when = System.currentTimeMillis();

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

    Context context = getApplicationContext();
    CharSequence contentTitle = "Uploading File";
    CharSequence contentText = "Upload in progress. Stage #" + i;

    Intent notificationIntent = new Intent(this, FileUploader.class);
    PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
            notificationIntent, 0);

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

    mNM.notify(R.layout.main, notification);

The problem is that when I press home button during upload – FileUploader activity instance which was launched from Gallery becomes “stopped” and when I tap notification – 2nd FileUploader activity instance is launched.

So is it any way to “return” to the first activity when tapping notification instead of launch new one?

I’ve tried following ways but non of them work here:

  1. call finish() in FileUploader.onStop() method – activity is closed when switching from portrait to landscape.

  2. set android:launchMode=”singleTask” for FileUploader activity in AndroidManifest.xml – after this my applcation starts to appear in Recent Applications list, which is not acceptable since it allows to launch FileUploader activity from there and as I mentioned above it only should be launched by sending android.intent.action.SEND intent from Gallery/Camera.

  3. Use same intent as was used to launch 1st instance – 2nd instance still created and following warning is in logs:

    04-12 17:01:17.041: WARN/ActivityManager(1289): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=android.intent.action.SEND typ=image/jpeg cmp=.FileUploader bnds=[0,628][480,723] (has extras) }

I’ve also tried to change line:

    Context context = getApplicationContext();

with

    Context context = this; // FileUploadServiceContext

But this doesn’t help.

Hmmm. I thought, maybe I launch wrong activity. Probably I should launch “parent” activity for my FileUploader.
For example: if I launch FileUploader from Gallery, then tap Home, then launch Gallery from Home screen again – I return to my Activity. So I wonder, maybe I need to launch Gallery/Camera from notification. But 2 questions:

  1. how to determine what exactly was the parent of my activity?

  2. what to do if that parent was closed by the system?

  • 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-05-21T17:30:07+00:00Added an answer on May 21, 2026 at 5:30 pm

    Well, the only way I found to implement this is:

    android:excludeFromRecents="true" android:launchMode="singleTask"
    

    This is not 100% of what I want (eg. I can’t return to “parent” application) after resume, but is better than nothing.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I am writing an app with both english and french support. The app requests
I have thousands of HTML files to process using Groovy/Java and I need to
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.