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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:16:59+00:00 2026-06-06T11:16:59+00:00

I have an text reader app that is designed to receive intent from Android

  • 0

I have an text reader app that is designed to receive intent from Android system when I click on a text file to open it. But my app isn’t on the list popped up by the system. Below are my codes:

Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.broadcastreceivertest1"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".BroadcastReceiverTest1Activity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<receiver android:name="MyBroadcastReceiver"> 
<intent-filter> 
<action android:name="android.intent.action.ACTION_VIEW" /> 
<action android:name="android.intent.action.ACTION_EDIT" /> 
<action android:name="android.intent.action.ACTION_PICK" /> 
<data android:scheme="file" /> 
<data android:mimeType="*/*" /> 
<data android:pathPattern=".*\\.txt" />    
<data android:host="*" /> 
</intent-filter> 
</receiver> 

</application>

</manifest>

My extended BroadcastReceiver

public final class MyBroadcastReceiver extends BroadcastReceiver {
private String TAG = "MyBroadcastReceiver";

@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Intent i = new Intent(context, BroadcastReceiverTest1Activity.class);
i.putExtra("URI", intent.getData());
context.startActivity(i);
Log.d(TAG, "Leaving onReceived...");
}
}

My activity to be opened by the broadcast receiver

public class BroadcastReceiverTest1Activity extends Activity {

private String uri ="";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Intent intent = getIntent();

final String action = intent.getAction();

if(Intent.ACTION_VIEW.equals(action)){
uri = intent.getStringExtra("URI");
TextView textView = (TextView)findViewById(R.id.textView);
textView.setText(uri);

}

}
}

Thanks!

  • 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-06T11:17:01+00:00Added an answer on June 6, 2026 at 11:17 am

    You need to associate your app with file extension. To do so, add these two line within intent filter and u’r good to go

    <data android:scheme="file" />
    <data android:mimeType="*/*"/>
    <data android:pathPattern=".*\\.pdf" />
    

    And your manifest would be look like this

    <activity name="com.your.activity">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="file" />
            <data android:mimeType="*/*" />
            <data android:pathPattern=".*\\.txt" />
        </intent-filter>
    </activity>
    

    <data android:scheme="file" /> => this define that the file must be local, not from http or else

    <data android:mimeType="*/*" /> => match any mime type

    <data android:pathPattern=".*\\.txt" /> => this is where you specify what extension you want to match

    Hope this help

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

Sidebar

Related Questions

I have created an Android RSS Reader App.I have a text marquee in my
I have text I am displaying in SIlverlight that is coming from a CMS
I have text file with some stuff that i would like to put into
I have an app that is parsing the html page and extracts some text
Have an app written that automatically reads out received text messages when they arrive.
I have added 3 text file resources to an app and am trying to
We have an App for iOS that renders an enormous amount of text: http://itunes.apple.com/br/app/biblia-sagrada/id370178518?mt=8
I have a rails app that creates a kml file and successfully loads it
I have an Ajax request from a page in my Rails app that looks
I have an rss reader app which works perfectly on some feeds, but on

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.