phonegap在android中应用

1、phonegap到1.5版本便更名为cordova,所以应使用import org.apache.cordova.DroidGap替换import  com.phonegap.*;

2、改变app icon

在AndroidManifest.xml中找到application,改变android:icon的值;若要改变应用名就改android:lable。

3、加载程序时定义背景

import org.apache.cordova.DroidGap;

import android.os.Bundle;

public class MainActivity extends DroidGap{

@override

public void onCreate(Bundle saveInstanceState){

super.onCreate(saveInstanceState);

super.setIntegerProperty("splashscreen",R.drawable.loading_icon); //Loading page icon

super.loadUrl("file:///android_asset/www/index.html");

}

}

4、全屏及去除标题栏

在AndroidManifest.xml中编辑activity,添加android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"。

<activity
    android:name=".MainActivity"
    android:label="@string/app_name" android:configChanges="orientation|keyboardHidden"
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
</activity>

5、报错reference error cannot find variable:你的js代码有误,请检查

pg camera json error:这是由于phonegap1.5版本将camera.getPicture函数缺省的destinationType值变为FILE_URI,而开发人员不小心错写为FILE_URL,故你要手工写入destinationType的值

navigator.camera.getPicture(onSuccess,onFail,{destinationType:Camera.DestinationType.FILE_URI});


6、为按钮添加事件

ducument.addEventListener("backbutton",backFunction,false);//返回键

document.addEventListener("menubutton",menuFunction,false);//菜单键

document.addEventListener("searchbutton",searchFunction,false);//搜索键

注销document.removeEventListener("backbutton",backFunction,false);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值