【问题标题】:How to create Android Service Without interval in Appcelerator/titanium Android?如何在 Appcelerator/titanium Android 中创建无间隔的 Android 服务?
【发布时间】:2016-01-06 11:17:24
【问题描述】:

我想在 appcelerator android 中创建一个服务,当我单击下载按钮时它会启动,只有在下载中断/失败或网络不存在时才会停止。

我怎样才能实现它?我已经参考了这篇文章 http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Android.Service

我正在关注此http://docs.appcelerator.com/platform/latest/#!/guide/File_Uploads_and_Downloads 以下载内容(视频)

我面临的另一个问题是,我无法访问 UI,或者 UI 几乎没有响应,尽管我可以上下滚动。在android上进行下载时。这就是 UI 的样子,我在点击下载按钮时调用了一个函数。

注意:每个元素,浅灰色矩形就像一个手风琴控件,在点击时切换(展开和缩回)。

我在videoDownloader.js 文件中编写了这样的代码

 function downloadVideos(video_download_url){
       var xhr = Titanium.Network.createHTTPClient({
        onload: function() {
            // first, grab a "handle" to the file where you'll store the downloaded data
            var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'video.mp4');
            f.write(this.responseData); // write to the file

            timeout: 10000
    });
    xhr.open('GET',video_download_url);
    xhr.send();
    }

【问题讨论】:

    标签: javascript android titanium-alloy appcelerator-mobile


    【解决方案1】:

    您可能想查看this module,它会为您处理所有事情。

    【讨论】:

    • 它看起来像它的 64 位,所以应该可以在 iOS 和 Android 上运行,然后我猜。而且Mads Moller(作者)非常善于回应问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-05
    相关资源
    最近更新 更多