List my app in the list of programs that can open a document

2

When we receive an email with an attached file and click on this file it is shown a list of programs that can open this file. How do I make my app appear on this list too?

I'm sorry, I'm new to the tool and did not see the answer. I changed my code and it still does not work.

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

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

    <activity android:name=".Arquivos"/>
    <activity android:name=".NomeSenha" />
    <activity android:name=".Bateria" />
    <activity android:name=".Tensao"/>
</application>

    
asked by anonymous 09.01.2017 / 14:55

2 answers

1

You need to create a IntentFilter , Intentions filters , in your activity within manifest.xml , which will add your application to the specific list.

An example when clicking on the share would be used <action> in < a href="https://developer.android.com/guide/topics/manifest/intent-filter-element.html"> <intent-filter> :

<intent-filter>
        <action android:name="android.intent.action.SEND"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <data android:mimeType="text/plain"/>
        <data android:mimeType="image/*" />
</intent-filter>

It would look like this:

<activity
    android:name=".ActivityNewUrl"
    android:label="@string/title_activity_new_url"
    android:windowSoftInputMode="stateUnchanged">
    <intent-filter>
        <action android:name="android.intent.action.SEND"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <data android:mimeType="text/plain"/>
        <data android:mimeType="image/*" />/>
    </intent-filter>
</activity>

Note: You have to check what kind of file you want other applications to see. In this example I set minType to text/plan and image , which means that it will show the options when sharing text or images. See more here Enabling other apps to start your activity .

Image :

Readmorehere:

09.01.2017 / 15:29
0

I was able to work if in the program that lists the files of the mobile phone I select the "share with" option. My program appears in the list and it runs (now I'm having trouble receiving the file but that's another problem). What I wanted is not this, is to give a short click on the file name and my program appears in the list. Now for example appears the text editors, PDF viewer and others. I wanted my app to be on this list, like programs that open this file and not just receive a share.

    
10.01.2017 / 15:42