1

i'm developing an android app, this app generate text files that contains a Json string, the files are saved using .fr extension. What i want is that when the user open a file with .fr extension the system run my app. I read other similar questions in stack and i add an intent filter in my manifest.xml, but it don't run. If i try to open a file with fr extension android don't show my app in the list. I try to make this with txt file, is the same problem. I ask you why it don't run and if i will fix the problem how can i read the file. thanks.

here my manifest:

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

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@style/MyTheme" >
        <activity
            android:name=".Main"
            android:screenOrientation="portrait"
            android:label="@string/app_name" >
            <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.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="application/fr" />
                
            </intent-filter>
           
        </activity>

        <activity android:name=".Settings"
            android:label="Settings"
            android:screenOrientation="portrait"
            android:parentActivityName=".Main">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".Main"/>

        </activity>
        <activity android:name=".Archivio"
            android:label="Archivio"
            android:screenOrientation="portrait"
            android:parentActivityName=".Main">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".Main"/>
        </activity>

        <activity android:name=".Info"
            android:label="Info"
            android:screenOrientation="portrait"
            android:icon="@drawable/ic_action_about"
            android:parentActivityName=".Main">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".Main"/>
        </activity>

        <activity android:name=".Training"
            android:label="Allenamento"
            android:screenOrientation="portrait"
            android:parentActivityName=".Archivio">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".Main"/>
        </activity>

        <activity android:name=".GraficoTempoElevazione"
            android:label="Allenamento"
            android:screenOrientation="portrait"
            android:parentActivityName=".Archivio">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".Main"/>
        </activity>

        <activity android:name=".GraficoTempoPasso"
            android:label="Allenamento"
            android:screenOrientation="portrait"
            android:parentActivityName=".Archivio">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".Main"/>
        </activity>

        <activity android:name=".GraficoTempoVelocita"
            android:label="Allenamento"
            android:screenOrientation="portrait"
            android:parentActivityName=".Archivio">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".Main"/>
        </activity>

        <activity android:name=".GraficoDistanzaElevazione"
            android:label="Allenamento"
            android:screenOrientation="portrait"
            android:parentActivityName=".Archivio">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".Main"/>
        </activity>

        <activity android:name=".GraficoDistanzaPasso"
            android:label="Allenamento"
            android:screenOrientation="portrait"
            android:parentActivityName=".Archivio">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".Main"/>
        </activity>

        <activity android:name=".GraficoDistanzaVelocita"
            android:label="Allenamento"
            android:screenOrientation="portrait"
            android:parentActivityName=".Archivio">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".Main"/>
        </activity>

        <activity android:name=".GpsTest"
            android:screenOrientation="portrait"
            android:label="@string/stringGPS" >
        </activity>

        <service android:name=".LocationLoggerService">

        </service>
    </application>
    <uses-permission
        android:name="android.permission.ACCESS_FINE_LOCATION" />

</manifest>
marsec
  • 133
  • 1
  • 1
  • 5
  • What do you mean by 'open the file' ? Also note that a simple text file with an extension of '.fr' will not match your intent-filter of 'application/fr' - you probably don't want to use mime-type. See http://stackoverflow.com/questions/3760276/android-intent-filter-associate-app-with-file-extension – GreyBeardedGeek Feb 25 '15 at 18:24
  • Thank you very much for the link! now when i try to open a file with this extension start my app. but how can i read the file when the app start? – marsec Feb 25 '15 at 21:45
  • By reading the documentation - http://developer.android.com/guide/components/intents-filters.html – GreyBeardedGeek Feb 26 '15 at 01:16

0 Answers0