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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:09:14+00:00 2026-05-24T01:09:14+00:00

I had used the Intent code for sending Email , I was able to

  • 0

I had used the Intent code for sending Email , I was able to send the email Successfully,
but my problem is if the user click the Gmail App and open Inbox click a email and press Home Key , then open my app and click Email Button it opens the Inbox rather than the
composing page ( i.e , it would go to whatever the last view I had been on in Gmail, either inbox, or a message thread, or even a draft message ) so i planned to kill the background Gmail Process but Mr.Commonsware has mentioned in his answer that we cannot kill another app from our application so i try to kill the Back ground process and also restart package all of my efforts are went in vain.

Here’s my Email Sending code

public static ComponentName name = null;

    name = new ComponentName(
            "com.android.email",
            "com.android.email.activity.MessageCompose");

Intent intent = new Intent(Intent.ACTION_SEND);
        intent.addCategory(Intent.CATEGORY_LAUNCHER);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
                | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);

        intent.setComponent(name);
        intent.setType("application/octet-stream");
        intent.putExtra(Intent.EXTRA_EMAIL,
                new String[] { " " });
        intent.putExtra(Intent.EXTRA_SUBJECT, "Test");
        intent.putExtra(
                Intent.EXTRA_TEXT,
                Html.fromHtml("<b> test Message</b>"));
        intent.putExtra(Intent.EXTRA_STREAM,
                Uri.parse("file:///" + "sdcard/download/" + imgfilename));  

        startActivity(intent);

here is my restartPackage code

            ActivityManager aM = (ActivityManager);
getApplicationContext().getSystemService(getApplicationContext().ACTIVITY_SERVICE);
            aM.restartPackage("com.android.email");

Here is my Kill BackGround Process Code

                        ActivityManager aM = (ActivityManager)
        getApplicationContext().getSystemService(Catalogue.content_holder.getApplicationContext().ACTIVITY_SERVICE);
                        aM.killBackgroundProcesses("com.android.email");

Here is my code which fetches all running Application and check wether email app is already running or not , if it is running then kill that process

    ActivityManager manager =  (ActivityManager);    getApplicationContext.getSystemService(getApplicationContext.ACTIVITY_SERVICE);
            List<RunningAppProcessInfo> activityes = ((ActivityManager) manager).getRunningAppProcesses();

            for (int iCnt = 0; iCnt < activityes.size(); iCnt++){

                System.out.println("APP: "+iCnt +" "+ activityes.get(iCnt).processName);

if (activityes.get(iCnt).processName.contains("com.android.email")){
                    android.os.Process.sendSignal(activityes.get(iCnt).pid, android.os.Process.SIGNAL_KILL);
                     android.os.Process.killProcess(activityes.get(i).pid);
                    //manager.killBackgroundProcesses("com.android.email");

//manager.restartPackage("com.android.email");  

                     System.out.println("Inside if");
                }

            }
  • 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-24T01:09:14+00:00Added an answer on May 24, 2026 at 1:09 am

    It was fixed by just removing this Flag and added the following flags

             intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK 
                | Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | 
             Intent.FLAG_ACTIVITY_CLEAR_TOP 
    | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NO_HISTORY 
        | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED |
                Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had used the below code to get the row index of the UIPickerView
I have an xml layout that compiles fine but when I used the intent
i had used this plugin before, but now when i want to use it
I had used the links in fmt_url_map, but it does not work. I want
I had used the following code to find the length String str=strLenData.toString(); int ipLen=
I had used Server Explorer and related tools for graphical database development with Microsoft
I had used several ways to do some simple integer arithmetic in BASH (3.2).
I'm looking into development standards fro JavaScript. I had previously used Doulgas Crockfords Javascript
I had a property that used to be not-null=true. Values aren't necessary for that
I used to use a guitar tab site and it had a feature where

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.