标签: cordova-plugins

如何在android webview中实现phonegap/cordova?

我只需要几分钟时间就可以告诉我这些步骤是否适合在android webview中实现cordova:

编辑:好的我终于让它工作这些是正确的步骤:

1)我创建项目:cordova create hello com.example.hello HelloWorld并输入文件夹

2)cordova platform add android,cordova run android(创建cordova.jar)=>启动应用程序=>设备已准备就绪

3)我使用以下代码在"/ res/layout"中创建cordova_layout.xml:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 

<org.apache.cordova.CordovaWebView 
android:id="@+id/cordova_web_view" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_weight="1" /> 


</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

4)导入项目(作为eclipse中的"现有项目")并在导入后添加到主java文件中:

  public class HelloWorld extends Activity implements CordovaInterface {


private CordovaWebView cordova_webview;
private String TAG = "CORDOVA_ACTIVITY";
private final ExecutorService threadPool = Executors.newCachedThreadPool();



@Override 
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.cordova_layout);
    cordova_webview = (CordovaWebView) findViewById(R.id.cordova_web_view);
    // Config.init(this); 
    String url = "file:///android_asset/www/index.html";
    cordova_webview.loadUrl(url, …
Run Code Online (Sandbox Code Playgroud)

android webview cordova cordova-2.0.0 cordova-plugins

2
推荐指数
1
解决办法
1万
查看次数

如何在没有用户操作的情况下自动打开应用程序在 Android 上接收推送

我正在尝试在收到推送通知时打开应用程序。

代码:

public class GCMIntentService extends GCMBaseIntentService {

    public GCMIntentService() {
        super("GCMIntentService");
    }

    @Override
    protected void onMessage(Context context, Intent intent) {
        Intent dialogIntent = new Intent(this, MyActivity.class);
        dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(dialogIntent);    
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我到目前为止。但我无法弄清楚 MyActivity.class 是什么。

假设我想启动应用程序,就是这样。我不想向 AndroidManifest.xml 添加另一个活动。

我不能简单地将 MainActivity.class 用于 Cordova 吗?

MyActivity.class 到底是什么?

android launching-application android-intent cordova-plugins

2
推荐指数
1
解决办法
5107
查看次数

带 LED 灯的条码扫描仪科尔多瓦

我使用插件 com.phonegap.plugins.barcodescanner 创建应用程序扫描二维码

但我无法在扫描时打开设备中的 LED 灯

如何解决问题

谢谢大家帮忙!

barcode-scanner flashlight cordova cordova-plugins

2
推荐指数
1
解决办法
1682
查看次数

离子插件添加phonegap-plugin-push导致404 Not Found错误

我在Ionic上关注如何开始推送通知的官方(并且相当棒)的文档.

但是,一旦说明安装了phonegap-plugin-push插件,我收到以下错误:

nikola@Nikolas-Mini ~/Desktop/ionicTesting/ionicPush
> ionic plugin add phonegap-plugin-push
Error: 404 Not Found: phonegap-plugin-push
at RegClient.<anonymous> (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:304:14)
at Request._callback (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:246:65)
at Request.self.callback (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/npm/node_modules/request/request.js:236:22)
at Request.emit (events.js:110:17)
at Request.<anonymous> (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/npm/node_modules/request/request.js:1142:14)
at Request.emit (events.js:129:20)
at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/npm/node_modules/request/request.js:1096:12)
at IncomingMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)
Run Code Online (Sandbox Code Playgroud)

任何人都知道为什么?我试着用cordova代替ionic,但我得到了同样的错误.

ionic-framework cordova-plugins ionic

2
推荐指数
1
解决办法
961
查看次数

如何使用 ES6/ES2015 通过 Apache Cordova 实时重新加载?

我一直在将 ES6/ES2015 用于一个项目,通过 Babel(ify) 转换为 ES5,并通过 budo 与 Browserify 捆绑。这提供了一个很好的工作流程,其中检测到对 ES6 文件的更改、转译和增量捆绑在内存中完成,没有任何文件 I/O,并且浏览器会被告知刷新。

我是 Cordova 的新手,我正在尝试使用类似的工作流程,其中浏览器被替换为本地 iOS/Android 应用程序内浏览器,并在更改时重新加载。

我已经将我的 config.xml 设置为使用“ http://192.168.1.8:9966/index.html ”的内容元素,这是我运行 budo 的笔记本电脑的 IP。

我认为某处需要“cordova prepare”,但我不确定如何整合它,或者budo是否需要拥有cordova.js或其他东西的副本。我对...

正在使用的插件:

com.telerik.plugins.wkwebview 0.6.5 "WKWebView Polyfill"
cordova-plugin-battery-status 1.1.0 "Battery"
cordova-plugin-camera 1.2.0 "Camera"
cordova-plugin-console 1.0.1 "Console"
cordova-plugin-dialogs 1.1.1 "Notification"
cordova-plugin-file 3.0.0 "File"
cordova-plugin-file-transfer 1.3.0 "File Transfer"
cordova-plugin-geolocation 1.0.1 "Geolocation"
cordova-plugin-globalization 1.0.1 "Globalization"
cordova-plugin-inappbrowser 1.0.1 "InAppBrowser"
cordova-plugin-network-information 1.0.1 "Network Information"
cordova-plugin-splashscreen 2.1.0 "Splashscreen"
cordova-plugin-webserver 1.0.3 "CordovaWebServer"
cordova-plugin-whitelist 1.0.0 "Whitelist"
Run Code Online (Sandbox Code Playgroud)

我在 iOS …

ios cordova cordova-plugins

2
推荐指数
1
解决办法
2259
查看次数

Ionic 2 Cordova网络信息插件参考错误

我已根据本教程将网络信息插件安装到我的Ionic 2应用程序中:

离子2 | 如何使用Cordova插件

但是,TypeScript无法编译,因为它无法在状态数组行中找到"连接"的引用.知道如何根据Platform,Page等为它编写import语句吗?

我的课:

import {NavController, NavParams} from 'ionic-framework/ionic';
import {Page, ViewController, Platform, Alert, Modal, Events} from 'ionic-framework/ionic';
import {forwardRef} from 'angular2/core';
import {OnInit} from 'angular2/core';
import {Injectable} from 'angular2/core';
import {TodosService} from '../../services/TodosService';
import {MyTodosItem} from '../../pages/my-todos-item/my-todos-item';

@Page({
  templateUrl: 'build/pages/my-todos/my-todos.html'
})
class TodayPage {

  constructor(
    private platform: Platform,
    private nav: NavController,
    private _events: Events,
    private _todosService: TodosService) {
    this._platform = platform;
    this._isAndroid = platform.is('android');
  }

  ngOnInit() {
    this.getItems();
    this._events.subscribe('item:updated', () => {
      this.getItems();
    });

    this.checkNetwork();
  } …
Run Code Online (Sandbox Code Playgroud)

reference cordova-plugins ionic2 angular

2
推荐指数
1
解决办法
4293
查看次数

Android Ionic Cordova - 错误:无法获得已安装模块的绝对路径

我已经创建了一个自定义插件,我正在尝试通过cmd添加它以获得以下错误

> cordova plugin add C:\r\work\custom_plugins\cordova-plugin-webrtc-video-call -
-save
x Running command - failed!

[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova plugin add
        C:\r\work\custom_plugins\cordova-plugin-webrtc-video-call --s... (exit
        code 1):

        Error: Failed to get absolute path to installed module


C:\r\work>
Run Code Online (Sandbox Code Playgroud)

config.xml中

<?xml version='1.0' encoding='utf-8'?>
<plugin id="cordova-plugin-webrtc-video-call" version="1.0.1" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
    <name>WebrtcVideoCall</name>
    <js-module name="WebrtcVideoCall" src="www/WebrtcVideoCall.js">
        <clobbers target="cordova.plugins.WebrtcVideoCall" />
    </js-module>
    <platform name="android">
        <config-file parent="/*" target="res/xml/config.xml">
            <feature name="WebrtcVideoCall">
                <param name="android-package" …
Run Code Online (Sandbox Code Playgroud)

android cordova ionic-framework cordova-plugins ionic2

2
推荐指数
1
解决办法
2730
查看次数

尝试访问相机时,Cordova应用程序崩溃

我有一个已实现Cordova Camera插件的Cordova应用程序(在Android上运行),我有一个简单的“ click”事件,该事件调用以下代码,然后弹出消息:

“是否允许MyHQAPP访问设备上的照片,媒体和文件?”

我单击“允许”,应用程序立即关闭?我已经检查了ADB错误日志,可以在下面看到以下错误

谁能说出问题所在-请注意,我正在使用ngCordova插件来实现相机功能 http://ngcordova.com/docs/plugins/camera/

08-07 11:33:19.712 14954 15032 E PluginManager: Uncaught exception from plugin
08-07 11:33:19.712 14954 15032 E PluginManager: android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/com.mytechnologies.myapp_2017/cache/.Pic.jpg exposed beyond app through ClipData.Item.getUri()
08-07 11:33:19.712 14954 15032 E PluginManager:         at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
08-07 11:33:19.712 14954 15032 E PluginManager:         at android.net.Uri.checkFileUriExposed(Uri.java:2346)
08-07 11:33:19.712 14954 15032 E PluginManager:         at android.content.ClipData.prepareToLeaveProcess(ClipData.java:845)
08-07 11:33:19.712 14954 15032 E PluginManager:         at android.content.Intent.prepareToLeaveProcess(Intent.java:8941)
08-07 11:33:19.712 14954 15032 E PluginManager:         at android.content.Intent.prepareToLeaveProcess(Intent.java:8926)
08-07 11:33:19.712 14954 15032 E PluginManager:         at android.app.Instrumentation.execStartActivity(Instrumentation.java:1690)
08-07 11:33:19.712 …
Run Code Online (Sandbox Code Playgroud)

android cordova cordova-plugins ngcordova

2
推荐指数
1
解决办法
1101
查看次数

cordova-plugin-console不支持这个项目的cordova-ios版本

我已将环境从离子1升级到离子3.19.1.但是,我的项目仍然是离子v1(或者如果我在v1下面没有误,不确定)

我跑了命令

ionic cordova build ios --v1
Run Code Online (Sandbox Code Playgroud)

这是失败的.

Discovered plugin "cordova-plugin-console" in config.xml. Adding it to the project
Installing "cordova-plugin-console" for ios
Plugin doesn't support this project's cordova-ios version. cordova-ios: 4.5.4, failed version requirement: <4.5.0
Skipping 'cordova-plugin-console' for ios
Run Code Online (Sandbox Code Playgroud)

它是什么意思以及如何解决它?

我的环境如下:

ionic version 3.19.1
cordova version 8.0.0
npm version 5.6.0
macos High Sierra 10.13.1
xcode 9.2
Run Code Online (Sandbox Code Playgroud)

ios ionic-framework cordova-plugins ionic3

2
推荐指数
1
解决办法
3731
查看次数

科尔多瓦:如何将文件移到“下载”文件夹?

情况:

在我的移动应用程序中,我需要下载一个文件并将其存储在“下载”文件夹中。

下载部分工作正常。该文件已从服务器正确下载并存储在以下文件夹中:

file:///storage/emulated/0/Android/data/org.cordova.MY_APP_NAME.app/my_file.pdf
Run Code Online (Sandbox Code Playgroud)

但是该位置并不是真正的用户友好型。

要访问它,我必须转到:内部存储/ Android /数据/ org.cordova.MY_APP_NAME.app /

因此,我需要将其移至主下载文件夹。

文件传输是我无法完成的。

我知道关于SO已经有几个类似的问题。

我已经尝试了所有方法,但对我来说真的没有用,我无法在实际的Download文件夹中看到该文件。

项目信息:

我使用的类星体Vuejs科尔多瓦

平台

目前,我正在使用Android。但理想情况下,我正在寻找一种适用于Android和IOS的解决方案。

代码:

下载代码:

var fileTransfer = new FileTransfer() // eslint-disable-line
var uri = encodeURI('https://MY_SERVER_PATH')

fileTransfer.download(
  uri,
  cordova.file.externalApplicationStorageDirectory + 'my_file.pdf',
  entry => {
    console.log('download complete: ' + entry.toURL())
    this.moveFile(entry.toURL())
  },
  error => {
    console.log('download error source ' + error.source)
    console.log('download error target ' + error.target)
    console.log('download error code' + error.code)
  },
  false,
  {
    headers: {
      'Authorization': …
Run Code Online (Sandbox Code Playgroud)

android cordova cordova-plugins vue.js quasar-framework

2
推荐指数
1
解决办法
2748
查看次数