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

  • Home
  • SEARCH
  • 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 8154381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:19:44+00:00 2026-06-06T16:19:44+00:00

When a user downloads a file using Android I want my custom activity to

  • 0

When a user downloads a file using Android I want my custom activity to be launched to open that file. For example, my custom activity should show up in the ‘Complete action using’ alert box when the file is launched.

Is there any examples to see how this is done?

  • 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-06-06T16:19:47+00:00Added an answer on June 6, 2026 at 4:19 pm

    If I am correct, this will be what you want in your manifest:

    <activity
         android:name=".NameOfYourActivity"
         android:label="@string/app_name" >
                <intent-filter>
                      <action android:name="android.intent.action.VIEW" />
                      <category android:name="android.intent.category.DEFAULT" />
                      <data android:mimeType="text/plain" />
                </intent-filter>
    </activity>
    

    For more information, read Intents and Intent Filters from the developer website.

    Also, here is a sample of an activity you could use to display a file.

    public class MIMEsActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
    
        //Get the intent that has the information about the file.
        Intent sender = getIntent();
    
        //In this example I'm simply displaying the file's contents
        //in a TextView.
        TextView view = (TextView) findViewById(R.id.textview);
    
        //Check to see if there was an intent sent.
        if(sender != null) {
    
            //Get the file.
            File file = new File(sender.getData().getPath());
    
            /*
                DO STUFF HERE WITH THE FILE
                I load the text of the file and send it
                to the TextView.
            */
            StringBuilder text = new StringBuilder();
            try {
                BufferedReader br = new BufferedReader(new FileReader(file));
                String line;
    
                while ((line = br.readLine()) != null) {
                    text.append(line);
                    text.append('\n');
                }
            }
            catch (IOException e) {
                //You'll need to add proper error handling here
            }
    
            view.setText("PATH: " + sender.getData().getPath() + "\n\n" + text);
            //Done doing stuff.
        }
        //If an intent was not sent, do something else.
        else {
            view.setText("You did not get a file!");
        }
    
    }
    

    }

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

Sidebar

Related Questions

I want to allow a user to download an html file using a php
I have an application (winforms) that downloads a file to user's temporary folder, then
I have an iOS application that downloads an xml file using: NSURL *queryURL =
I'm using a AsyncTask that downloads an apk file and then install it at
I'm giving a user a link to download a csv file ...just using Click
Normally, when I want to allow a user to download a file without revealing
I want to allow only registered user's to download a .mp3 file. So, I
I have a code that downloads videos from a URL. I am using AsyncTask.
i want to create a text file from a string. currently i am using
I'm trying to setup a servlet so that users on Android handsets/tablets (using the

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.