Archive for January, 2013

Why there is not built in app for this shit.
What i found is this:
I hope it will work


I have two activities in my project:

  • native java activity
  • phonegap activity

i invoke the native activity from phonegap with normal javascript interface like in my previous post and it works fine.

After The user is done in the native activity he suppose to press the back button and the phonegap activity should understand that the native activity has finished and to try and grab a number from the native code from with javascript with the phonegap js interface.

I’m trying all kind of javascript stuff to make it happen.

i tried jqm page events, js onload, js onfocus and nothing worked so i moved to find some other solution.

I just added a refresh button on the phonegap html page to a user can manually refresh.

this is lame and i hope i will find a better solution.

ok. so now i’m updating some static integer on the native java code and when user pushes back button it can press another button ‘refresh’ that reads that static integer with phonegap js interface. pretty lame, because if the user will not   press it nothing will be updated and the database will remain unchaned.

so i typed in google “phonegap event from java” and i found this post:!topic/phonegap/WuihERTBK_M%5B1-25-false%5D

found an answe by one Simon that says

Yeah, you want to make a call to your plugin and when you send back your initial PluginResult you want to:


that way you can send multiple results back to your page. You just need to make sure to setKeepCallback to true each time you return a result.
Check out the NetworkManager code for an example:

this must be tested.

Found in the attached link some code and found the function:

194      * Create a new plugin result and send it back to JavaScript
195      *
196      * @param connection the network info to set as navigator.connection
197      */
198     private void sendUpdate(String type) {
199         if (connectionCallbackContext != null) {
200             PluginResult result = new PluginResult(PluginResult.Status.OK, type);
201             result.setKeepCallback(true);
202             connectionCallbackContext.sendPluginResult(result);
203         }
204         webView.postMessage(“networkconnection”, type);
205     }
so i guess i need to understand better what is CallbackContext for phonegap.
found some links:
ok. i guess I will create me a phonegap plugin and use the code above to update the phonegap code with new data. because I want the db to be sqlLite under phonegap. not the native.

download –

found a nice post on

it was relevant to abs4.0.0. now i download 4.2.0. so here is what i did:

  • download
  • extracted and copied library folder to my workspace.
  • Created a new project “abs4.2.0” out of existing source, and also checked “copy to workspace”.


  • copy “android-support-v4.jar” (under libs) from your final project (with your code on it) and move it to the same place under the “abs4.2.0” project.
  • Go to project “abs4.2.0” properties, check the “Android 4.2.0” target and check “is Library”.


  • Go to menu in Project->Clean and than Project->Build Project. build abs4.2.0 project.
  • So I have a ton of prasing XML errors and my abs4.2.0 proj looks like shit.
  • I tried to add android-tools.jar to the Build path.
  • I tried to “Add Android Support library” under projProperties->Android Tools->Add Support library. I updated with revision-11.
  • but still i got a bunch of errors like this:Description Resource Path Location Type
    error: Error parsing XML: no element found abs__action_bar_home.xml /abs4.2.0/res/layout line 1 Android AAPT Problem
  • ok. the problem was that eclipse deletes the content of most src+res+xml files in the abs4.2.0 project. So I just copied again from the extracted library folder the AndroidManifest.xml and the entire res+src folder and copied it the abs4.20 project in my workspace. I also had to recreate “.proj” file because it was erased too by eclipse.
  • This is the problem with free software… 😦
  • Now when abs4.2.0 is ok I added it to my project as an Android library.


I try to make a cool front page to my phonegap app.

I want four squares, similar to the squares u c on the android store app.

so I started to look for the css rules to make it happen.

First i created 4 divs (height=width=50%) and placed them in the content.

The page didn’t show anything so I put another css class for the jqm content div with height:100%, so i will show.

Then I wanted to place content in each square, this was rather hard I couldn’t find someting that works until I saw this post:

than i got it. the solution was

position: relative;
top: 50%;
left: 50%;
margin-top: -1.2em;

The html:

<div data-role=”content” class=”homepagecontent”>

<div class=”linkrect topleft”><p>1</p></div>
<div class=”linkrect topright”><p >2</p></div>
<div class=”linkrect bottomleft”><p >3</p></div>
<div class=”linkrect bottomright”><p >4</p></div>


The CSS:

padding:0 ;
padding:0 ;



.linkrect p{
position: relative;
top: 50%;
left: 50%;
margin-top: -1.2em;
float: left;
background: red;

float: right;
background: green;

float: left;
background: yellow;

float: right;
background: pink;



for a while i was straggling with ready templates and stolen css from some websites.

First i tryied to watch some video tutorials (lynda, video2brain etc) on css but its just so boring.

so i need to take more seriously and try to figure it out one and for all. After all, css can’t be so hard.

I pretty much know the css basics. and i feel no to hot on css transitions. so i find this website. whats up with santa in the header?

pretty lame. and i know this. pretty basic.

next search result,

CSS3 Transition Tutorials to Create a Single Page Website

looks pretty good, lots of scenario cases and examples.


I have a native activity that captures audio. I had to go native on that one because of realtime issues.

So no I have my fancy html5 phonegap app and i need to trigger the native activity.

I encountered on that post:

How to call an Android Activity from PhoneGap

and try to implement the first answer.

on the native code I just copied this

appView.addJavascriptInterface(this, “MainActivity”);

without this code

super.init(); // Calling this is necessary to make this work

and the activity crashed.

when i included that line everything worked great.


returning values from native functions to phonegap javascript code:

public void onCreate(Bundle savedInstanceState)
super.init(); // Calling this is necessary to make this work
appView.addJavascriptInterface(this, “MainActivity”);

public int testReturned ()
return 42;

and from the phonegap js side:

alert (window.MainActivity.testReturned());


and it worked… 🙂

I needed to save the date. I sick of the differences in format of the different APIs (sql, phonegap, javascript).

enough is enough.

so i’m moving to using TIMESTAMPs instead…

Current datetime to timestamp


timestamp to datetime

var date = new Date(timestamp * 1000);