【问题标题】:Need to set the wallpaper of the phone from my ionic 2/3 app需要从我的 ionic 2/3 应用程序设置手机壁纸
【发布时间】:2019-03-04 21:46:43
【问题描述】:

我正在开发 ionic 3 应用程序。我没有找到任何与设置壁纸相关的插件,正在寻找插件或将本地或远程图像设置为来自 ionic 应用程序的壁纸的方法。

我找到了一个,但无法让它工作( https://github.com/fbsanches/cordova-plugin-wallpaper) .不知道这个问题。

window.plugins.wallpaper.setImage(fileEntry.toURL(), function (error) {
          if (error) {
            console.error(error);
          } else {
            console.log('Success setting wallpaper.');
          }
        });

【问题讨论】:

  • 什么类型的设备?安卓、Windows、iOS?全部?
  • 我已经尝试过了,但没有任何反应。如果您有工作示例,请分享一下
  • 你看github页面了吗:window.plugins.wallpaper.setImage('path/to/image.png', function(error) { if (error) { console.error(error); } else { console.log('设置壁纸成功'); } });
  • 是的,我根据文档尝试了该方法,您也提到了。

标签: ionic-framework ionic2 ionic3


【解决方案1】:

基于项目GitHub的issue #10,导入后添加

declare var window: any;

在contractor中,必须包含private platform: Platform作为参数:

setWallpaper(url){
  this.platform.ready().then(() => {
    window.plugins.wallpaper.setImage(url);
        console.log('Success setting wallpaper.');
 });
}

【讨论】:

  • 我们如何使用手机存储路径中的图片?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多