Monday, August 30, 2010

AppEngine Tricks

So I'm working on quite a few Google AppEngine apps and recently, I need to delete all the data in the datastore. I've searched around the interwebs and most of the solution is by using the remote api that uses python. But I don't want to mess around with python so what I did is modify the request parameters from the Datastore viewer so that it displays 200 records at one time which then you can delete using the Delete button below.

Here's the sample URL:

https://appengine.google.com/datastore/explorer?app_id=YOURAPPID&namespace=&kind=Item&limit=200&offset=0&query=SELECT%20*%20FROM%20Item&viewby=kind

Friday, August 27, 2010

Life Stories for iPhone

I just started playing around with Objective-C for the Life Stories version in iOS 4.Then as usual, for newbies, I encountered a problem when displaying adView.

Basically the problem is that when your view changed, like you hit the back button or change to another view, while your adview is still loading, the call to - (void)bannerViewDidLoadAd:(ADBannerView *)banner and - (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error which ever is called will fail. Searching around the net, I found this StackOverFlow question and the solution helped me to fix my problem.

http://stackoverflow.com/questions/3359714/wierd-iad-error-causing-crash

So the solution is just to just remove the delegate of the adView and null its reference on the - (void)dealloc method.

adView.delegate = nil;
adView = nil;

Tuesday, August 24, 2010

SeekBar Preference

I just would like to share the code that I've posted in the Google Devs mailing list when someone asked about the SeekBar Preference.
public class SeekBarPreference extends DialogPreference{

private Context context;
private SeekBar volumeLevel;

public SeekBarPreference(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
}

protected void onPrepareDialogBuilder(Builder builder) {

LinearLayout layout = new LinearLayout(context);
layout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
layout.setMinimumWidth(400);
layout.setPadding(20, 20, 20, 20);

volumeLevel = new SeekBar(context);
volumeLevel.setMax(32);
volumeLevel.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
volumeLevel.setProgress(Integer.parseInt(getSharedPreferences().getString(getKey(),"32")));

layout.addView(volumeLevel);


builder.setView(layout);

super.onPrepareDialogBuilder(builder);
}

protected void onDialogClosed(boolean positiveResult) {
if(positiveResult){
persistString(volumeLevel.getProgress()+"");
}
}

}


This allows you to popup a seekbar that you can use to adjust some properties like volume, difficulty and other things where a slider would be useful. Then you use it like:


alarmVolume = new SeekBarPreference(this, null);
alarmVolume.setTitle("Volume");
alarmVolume.setSummary("Modify the volume of the alarm");
alarmVolume.setKey(PREF_ALARM_VOLUME);


and then can be added to a PreferenceScreen or PreferenceCategory




Monday, August 23, 2010

Android and OpenCV

From now on, I will try to post some tutorials on using OpenCV and Android. I'm planning to build a camera software that can do basic effects such as softening, increasing contrast, b/w effects, sepia and other stuff just by using opencv functions.

Hope to get some time to write my very first tutorial.

TimingLogger | Android Developers

TimingLogger | Android Developers

This is a very useful utility for timing parts of your code. I think this will be handy specially in my day job where I need to call lots of cpu intensive computations and I need to make sure they are optimized.

I will post a sample code and project later.

Saturday, August 21, 2010

Android Applications, Games and Wallpapers

Android Applications, Games and Wallpapers

Just trying out the Blog This! Chrome extension. Anyway this site contains most of the Android applications available in the Android Market. The site provides two ways to find applications either by category or typing the name or author of the application on the search box.

Give it a try and discover more Android apps.