Archive for the ‘PhoneGap’ Category

 

submission error loading page when post form. | jquery mobile

3月 16th, 2012

formの時、ajaxでエラーが出るのでなんか・・・
検索すると
mobileinitで

$.extend( $.mobile , {
ajaxFormsEnabled :false
});

$.mobile.ajaxFormsEnabled=false;

これしかない!
ってなっちゃうのですが、これがdoesn’t work for me な感じで。
単純に

<form ajax-data=”false” method=”POST” … >

だけで良いと言う結果。
まぁドキュメントが追いつかないのは良くあることなので仕方ないのですが。
検索しても色々なバージョンのドキュメントが散らばっているのもなかなか手強いところです。

Read full article | コメントは受け付けていません。

console.log()を出力させない。 | phonegap iOS

3月 2nd, 2012

とりあえず、phonegap.jsで DebugConsoleが定義されているので

if ( true ){
DebugConsole.prototype.log = function(message, maxDepth) {};
DebugConsole.prototype.warn = function(message, maxDepth) {};
DebugConsole.prototype.error = function(message, maxDepth) {};
window.console = new DebugConsole();
}

こんな感じで上書きするとconsole.logで何もしなくなります。

Read full article | コメントは受け付けていません。

リンクをsafariで開く | phonegap iOS

3月 2nd, 2012

外部ページもアプリで開いてしまうので、外部リンクは、safariで開くように変更します。
Classes AppDelegate.mを編集します。

- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
}

http://groups.google.com/group/phonegap/browse_frm/thread/7815d5e103fc18ac/a3ba58b1002af281?#a3ba58b1002af281
webViewを利用している人は、ここにドメインの振り分けを追加する感じで。

- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL];
if( [[url scheme] isEqualToString:@”http”] ||
[[url scheme] isEqualToString:@”https”])
{
[[UIApplication [...]

Read full article | コメントは受け付けていません。

whitelist rejection | phonegap iOS

3月 2nd, 2012

外部データ取得するときに PhoneGap.plist に追加する
ajax, imageなど全て必要。
Supporting Files : PhoneGap.plist

External hosts

Read full article | コメントは受け付けていません。

splash screen for android phonegap

3月 1st, 2012

起動時の黒画面に画像を入れてみる。
Activity.javaのonCreateにこれを追加するだけでした。

super.setIntegerProperty(”splashscreen”, R.drawable.splash);

後は、
res/drawable-*/splash.png
を各サイズで追加
http://developer.android.com/resources/dashboard/screens.html

を参考にして。
ldpi : 240*320
mdpi : 320*480
hdpi : 480*800
にしてみました。

Read full article | コメントは受け付けていません。

intent を作ってみる。 phonegap plugin for android

3月 1st, 2012

http://wiki.phonegap.com/w/page/36752779/PhoneGap%20Plugins
http://wiki.phonegap.com/w/page/36753494/How-to-Create-a-PhoneGap-Plugin-for-Android
ポイント
1・Pluginクラス( com.phonegap.api.Plugin)を継承してクラスを作成
2・プラグインを利用するためのjavascriptを作成( assets/www以下に .jsで設置してhtmlから読む
3・res/xml/plugins.xml に作成したクラスを追加
ここまでで、利用可。
4・パッケージ化する jarにしてライブラリに追加(phonegap.jar phonegap.jsと同じ配置で
端末メニューボタン→真ん中のshareボタンを追加してみました。
https://market.android.com/details?id=com.groundroad.aucru

Read full article | コメントは受け付けていません。

android端末のメニューボタン | phonegap

2月 14th, 2012

メニューボタンのイベントはこちら
http://docs.phonegap.com/en/1.4.1/phonegap_events_events.md.html#menubutton

document.addEventListener(”menubutton”, onMenuKeyDown, false);
function onMenuKeyDown() {
// Handle the back button
}

要件としては、
* androidのメニュー風なデザイン。
* 表示されたメニューボタンをクリックしたら遷移
* スクロール対応 ⇒ scrollstartで閉じる.close.
* 画面縦横切り替え対応→orientationchange
やり方。
* メニューの高さを決める。
* 画面の高さ - メニューの高さの枠をメニューの上に置く(透過)下のコンテンツをクリックさせない。この部分に触ったらメニューが閉じる。
* 横幅は、画面の横幅割るメニューの数。縦横画面が切り替わるので都度css書き換え。
出来た物はこちら。オークション落札価格相場検索アプリです。是非お試しください。
https://market.android.com/details?id=com.groundroad.aucru
画面はこんな感じです。縦のボーダーがぴったりでいい感じになりました。ヘッダーのデザインも替えたくなります。。。

https://twitter.com/#!/JunichiOtake/status/169064865900670977/photo/1

Read full article | コメントは受け付けていません。

android端末のsearchbutton event | phonegap

2月 13th, 2012

http://docs.phonegap.com/en/1.4.1/phonegap_events_events.md.html#searchbutton

document.addEventListener(”searchbutton”, yourCallbackFunction, false);

Read full article | コメントは受け付けていません。

html5 localstorage | phonegap

2月 13th, 2012

簡単なデータ保存にhtml5のlocalstorageを利用します。
http://docs.phonegap.com/en/1.4.1/phonegap_storage_storage.md.html

window.localStorage.setItem(”key”, “value”);
var keyname = window.localStorage.key(i);
// keyname is now equal to “key”
var value = window.localStorage.getItem(”key”);
// value is now equal to [...]

Read full article | コメントは受け付けていません。

timeout setting | phonegap

2月 5th, 2012

http://jquerymobile.com/test/docs/pages/phonegap.html
Android enforces a timeout when loading URLs in a webview which may be too short for your needs. You can change this timeout by editing a Java class generated by the Eclipse plugin for Android:
super.setIntegerProperty(”loadUrlTimeoutValue”, 60000);
ということで

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
[...]

Read full article | コメントは受け付けていません。