Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.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
Android从链接下载文件_Android_Android Download Manager_Download Manager - Fatal编程技术网

Android从链接下载文件

Android从链接下载文件,android,android-download-manager,download-manager,Android,Android Download Manager,Download Manager,在我为Android应用程序实现了一个解决方案后,我可以发布到web服务器并验证Google订单,然后发布一个下载链接。现在,我正在尝试编写一个应用程序代码,以读取thankyou.php页面上的链接 <a href="http://domain.com/218348214.dat">Download File</a> 该文件是一个“.DAT”扩展名,来自某个链接。应用程序应该在新页面中检索链接,并让客户下载文件 在清单文件中,您需要添加一个意向过滤器: &

在我为Android应用程序实现了一个解决方案后,我可以发布到web服务器并验证Google订单,然后发布一个下载链接。现在,我正在尝试编写一个应用程序代码,以读取thankyou.php页面上的链接

<a href="http://domain.com/218348214.dat">Download File</a>

该文件是一个“.DAT”扩展名,来自某个链接。应用程序应该在新页面中检索链接,并让客户下载文件


在清单文件中,您需要添加一个意向过滤器:

    <activity
        android:name="Downloader">
        <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:host="domain.com"
                android:scheme="http" />
        </intent-filter>
    </activity>

在清单文件中,您需要添加一个意图过滤器:

    <activity
        android:name="Downloader">
        <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:host="domain.com"
                android:scheme="http" />
        </intent-filter>
    </activity>

感谢您提供的信息,但仍然缺少一件事文件名是基于订单信息生成的变量,因此文件名不是静态的使用您的代码我仍然需要检索文件名,然后要求用户下载。更新了更多部分的答案,现在我更了解您的问题。非常感谢您的确认,有一件事是可以让用户留在应用程序中并从那里开始下载,而不是把他拉到web浏览器中完成他的操作吗?是的。你可以做到。看:谢谢分享。你的回答很有帮助,但是应用程序正在崩溃,我无法使用。谢谢你提供的信息,但是仍然缺少一件事文件名是基于订单信息生成的变量,因此文件名不是静态的。使用你的代码,我仍然需要检索文件名,然后要求用户下载。现在我更新了更多部分的答案更多地了解您的问题。非常感谢您的肯定,有一件事是可以让用户留在应用程序中并从那里开始下载,而不是将其拉到web浏览器以完成其操作吗?是的。你可以做到。看:谢谢分享。你的回答很有帮助,但是应用程序正在崩溃并通过我退出。
button.setOnClickListener (new View.OnClickListener () {
        @Override public void onClick (final View v) {
            Uri intentUri = Uri.parse("http://domain.com/" + filename);

            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.setData(intentUri);
            startActivity(intent);
        }
    });