Sunday, December 16, 2012

Android Listview RuntimeException - Your content must have a ListView whose id attribute is android.R.id.list

"Your content must have a listview whose id is android.r.id.list"

Just make sure your listview's id is @android:id/list.

<ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

Sunday, February 19, 2012

Blackberry Android Simulator Blinking Issue

Just submitted my first android port to Blackberry. In case you don't know, Blackberry Playbook OS 2 can run Android apps.

If you are using the simulator, you will notice whenever, you have an EditText, the whole screen will keep on blinking. After doing some research, I found the following:

http://twitter.com/#!/BlackBerryDev/status/169882992997711872

According to Blackberry, it seems like it's only the simulator that's doing that. I do not have an actual playbook, so I do not know if that's the case. So far, it took me half a day to convert my Android app to the Playbook.

The app I converted is the Ignite Study Flash Card.

PhoneGap and HTML5 - Ad CPM and CPC Calculator

Lately there are a lot of buzz about creating HTML5 PhoneGap applications on Android, iPhone, and Blackberry. I am not a big fan of writing HTML5 phone apps, since I think the HTML5 speed on the phone is still very laggy and slow.

If you have written any jquery mobile websites, you will probably see that the "apps" still feel like web pages whether than apps. It is very easy to tell whether an app is native or written in HTML5 on a phone. Feel free to comment below to let me know if you see any smooth HTML5 phone apps out there.

Anyways, I quickly wrote an app called Ad CPM and CPC Calculator. Below are the screen shots.




Description:


Ads CPM and CPC Calculator is the FIRST advertising calculator that lets you compute eCPC, eCPM, conversion rate, CTR, cost per conversion and campaign cost. You will never need to do tedious hand calculations again.

Ads CPM and CPC Calculator comes with three calculators:
Ad Rate Calculator lets you estimate the campaign cost by CPM and CPC.
Ad Inventory Calculator estimates impression and clicks given the budget.
Ad Spent Summary Calculator computes eCPC, eCPM, conversion rate, CTR, cost per conversion and campaign cost.


Android Market Link:

Download Ads CPM and CPC Calculator


Results:

I think the app is still quite laggy. It probably has to do with jquery mobile. Sometimes, the footer would bounce up or not refreshed probably. When switching through pages, it's not very responsive. You will have to click more than once on rare occasions.

I strongly recommend everyone to go native if possible. The only benefit for using HTML5 is it's fast and you can quickly launch to multiple platforms.

Sunday, January 15, 2012

IG Stock And Option Calculator For Android

Hi all, if you are a common stock trader using options to hedge your risk, you will find this tool useful. Whenever I purchase stocks, there are always a lot of calculations I compute to measure the risk.  I built this tool called IG Stock And Option Calculator to simply the whole tedious process.


Description:

IG Stock And Option Calculator includes 6 commonly used stock trading strategies for estimating risk.

Stock Return, Stop Loss, Long Call, Long Put, Covered Call, Protective Put.

Stock Return is for estimating or calculating your net profit from buying and selling a stock

Stop Loss calculates what prices you want to sell your stock at.

Long Call, Long Put, Cover Call, and Protective Put shows you the net profit and breakeven points.

Definitions:

A long call is simply the purchase of one call option.

A long put is simply the purchase of one put option.

A covered call is a financial market transaction in which holds a long position in an asset and writes (sells) call options on that same asset in an attempt to generate increased income from the asset.

A protective put is a risk-management strategy that investors can use to guard against the loss of unrealized gains. The put option acts like an insurance policy - it costs money, which reduces the investor's potential gains from owning the security, but it also reduces his risk of losing money if the security declines in value.


Product Features:
  •  Estimate stock return
  • Calculate sell price for stop loss order
  • Calculate break even price, net profit for long call
  • Calculate break even price, net profit for long put
  • Calculate break even price, net profit for long covered call
  • Calculate break even price, net profit for protective put
Screenshots:




Download Link:
IG Stock And Option Calculator

Saturday, December 17, 2011

Simple SMS Scheduler

Few weeks ago, I attended a seminar in a university. It was about gathering student resources to start a business. The club provides information about how to get fundings, mentors, etc. It also have a section about creating mobile apps. One of the guys there was talking about an SMS scheduler to send messages to his girlfriend. I found it simple and interesting.

I built the following part time:

App Name: Simple SMS Scheduler
Market Link: https://market.android.com/details?id=com.ignitesms.android

Description:

Simple SMS Scheduler is a clean and simple tool for sending automatic messages at a chosen time. 
Features:
  • Can choose recipients from contact list
  • Sent SMS shows up on default android messaging app
  • Optional delivery and sent reporting via status bar notification
  • Delivery and error history

Screenshots:





Feel free to try it out at https://market.android.com/details?id=com.ignitesms.android.

Feel free to let me know what you think. Feedback, criticisms are always welcomed.

Friday, December 16, 2011

Using javascript in webview to call native code

We will define two js functions in android

  • goToHome
  • showToast

for javacript calls from the webview.

You would call the functions like
<script type="text/javascript">
  window.jsinterface.goToHome()
  window.jsinterface.showToast()
</script>
Define the following in your android activity as an inner class.
public class JSInterface {
public void goToHome() {
Intent i = new Intent(getApplicationContext(), Home.class);
startActivity(i);
}
public void showToast(final String msg) { Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
}
}
In your onCreate function, intialize the webview similar to below:
WebView mWebView = (WebView) findViewById(R.id.webview);
mWebView.setVisibility(View.GONE);
mWebView.addJavascriptInterface(new JSInterface(), "jsinterface");
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int progress) {
Logger.v("webview", String.format("progress changed: %d", progress));
if (progress == 100) {
// webpage loaded completely
} else {
// webpage is loading
}
}
//@Override
public boolean onJsAlert(WebView view, String url,
String message, JsResult result) {
// if you do js alerts, this will show them as toast
Toast.makeText(getBaseContext(), message, Toast.LENGTH_SHORT).show();
result.confirm();
return true;
}
});

Basicly, that's it!

Android soft keyboard not showing on webview

Sometimes your webview may not show the soft keyboard.  This has to do with the focus and the timing that the webview is rendered.

If the soft keyboard does not show up, try to add the following to your webview:

mWebView.requestFocus(View.FOCUS_DOWN);
mWebView.setOnTouchListener(new View.OnTouchListener() {
       @Override
       public boolean onTouch(View v, MotionEvent event) {
           switch (event.getAction()) {
               case MotionEvent.ACTION_DOWN:
               case MotionEvent.ACTION_UP:
                   if (!v.hasFocus()) {
                       v.requestFocus();
                   }
                   break;
           }
           return false;
       }
   });