Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/386.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android共享并打开XML文件_Java_Android_Share_File Extension - Fatal编程技术网

Java Android共享并打开XML文件

Java Android共享并打开XML文件,java,android,share,file-extension,Java,Android,Share,File Extension,my app的用户可以创建包含父项和子项的自定义列表。我将这些信息存储在xml文件中。我想给用户 共享此文件的机会(电子邮件等)。如果其他用户单击此文件,我想打开应用程序并在我的列表中显示数据 到目前为止我做了什么: 用户可以创建一个xml文件并将其保存在存储器中。 现在的问题是:单击文件时如何打开应用程序?我是否必须创建自己的包含xml数据的文件扩展名 编辑: <activity android:name=".activities.TrainingSimpleSh

my app的用户可以创建包含父项和子项的自定义列表。我将这些信息存储在xml文件中。我想给用户 共享此文件的机会(电子邮件等)。如果其他用户单击此文件,我想打开应用程序并在我的列表中显示数据

到目前为止我做了什么: 用户可以创建一个xml文件并将其保存在存储器中。 现在的问题是:单击文件时如何打开应用程序?我是否必须创建自己的包含xml数据的文件扩展名

编辑:

<activity
            android:name=".activities.TrainingSimpleShowActivity"
            android:label="@string/title_activity_training_simple_show"
            android:screenOrientation="portrait">

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="file"
                    android:host="*"
                    android:pathPattern=".*\\.xml"
                    android:mimeType="*/*"  />
            </intent-filter>

        </activity>

不,您只需为应用程序设置一个意向过滤器

例如:

<intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="file"  android:host="*" android:pathPattern=".*\\.xml" android:mimeType="*/*"  />
</intent-filter>
也许您可以编写一个指南来为您的用户编写此XMl文件,当您的应用程序从意图中获取日期时,您可以搜索特定的标记或属性

希望这对你有帮助

更新 manifest.xml

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

<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.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="file"  android:host="*" android:pathPattern=".*\\.xml" android:mimeType="*/*"  />
        </intent-filter>
    </activity>
</application>

</manifest>


在manifest.xml中,在您想要处理数据的活动中,我认为在本例中是主要的。我建议你检查文档,好的,我把它添加到我想处理的活动中了。但是,当我单击xml文件并说“打开…”时,它不会在列表中显示我的应用程序。请立即尝试,我已修改了筛选器,请记住xml与xmlI不同。我已删除并安装了应用程序。仍然不会显示我已经发布了完整的清单文件,请检查您的文件是否正确
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dojester13.experimentintent">

<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.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="file"  android:host="*" android:pathPattern=".*\\.xml" android:mimeType="*/*"  />
        </intent-filter>
    </activity>
</application>

</manifest>