getActionBar and targetSdkVersion in Android development


Hi All,Recently I was trying to reiterate Android docs training just to fill in anything I missed previously. There I came across this piece of code:

// Initialize member TextView so we can manipulate it later  
     mTextView = (TextView) findViewById(R.id.edit_message);  
     // Make sure we're running on Honeycomb or higher to use ActionBar APIs  
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {  
       // For the main activity, make sure the app icon in the action bar  
       // does not behave as a button  
       ActionBar actionBar = getActionBar();  
       actionBar.setHomeButtonEnabled(false);  
     }

I tried to put that in a simple hello world example and it worked on an 2.2 emulator, however it failed to run on 4.0 emulator. On debugging it turned out that getActionBar was returning null value. Though there was on-line help available for some other directions it just came to my mind to check AndroidManifest.xml file. There I saw only “android:minSdkVersion=”8″” I remembered that there was a target SDK  as well which can be defined. So I checked a project created by eclipse and found the “android:targetSdkVersion=”15″” line and added it to “uses-sdk ” tag in AndroidManifest.xml and the app started working on 4.0 emulator.

This clears two things, first is that Idea IDE adds only minSDKVersion while eclipse adds targetSDKVersion as well. Which is reflected in new project also but could effect like this.

Second, if you search for getActionBar returning null you get loads of advice but maybe not this. So check if you are having this issue.

Thanks for reading. Thanks for Android guys for creating such a good documentation, which by and large so much better than Facebook developer docs. Only wish Facebook docs were also as clear as the Android docs.

Nexus 4 unboxing and first impressions


Google’s newest flagship handset, the LG Nexus, 4 is finally upon us. The highly anticipated stock Android smartphone features some of the highest-end specs of any phone currently on the market, but does it manage to satisfy? Stay tuned for a complete review. However, in the meantime, be sure to catch our unboxing and first impressions below.

http://supertechblog.com/2012/11/17/nexus-4-unboxing-and-first-impressions/

via Blogger http://ashish-yadav.blogspot.com/2012/11/nexus-4-unboxing-and-first-impressions.html

How to change look & feel of NetBeans IDE and application


Standard GUI toolkit of Java is Swing. NetBeans IDE and Platform is written in Swing. It’s widely used and accepted. It’s cross-platform and it’s doesn’t look very well under (GTK+) Linux.Read more here:http://devblog.virtage.com/2011/09/how-to-change-look-feel-of-netbeans-ide-and-application/

via Blogger http://ashish-yadav.blogspot.com/2012/11/how-to-change-look-feel-of-netbeans-ide.html

Deploying a facebook php app locally on Linux


As in my previous post I said that currently I am having a tryst with Facebook apps. Going further I thought of setting up a local environment where I could make changes locally and see them without uploading on heroku website. I find lots of issues which finally got resolved thanks to generous guys on internet. Following their path I am sharing the complete list of instructions I followed to deploy the Facebook app locally here.First of all you need to create an app on facebook and host it on heroku website following instructions from following link.
Please bear in mind that I chose to deploy the main app locally rather than creating a dev app.If you find any problem related to ssh keys these commands may help you as they did for me.

 # ssh -vT git@heroku.com  
Above command checks whether a secure connections with heroku site is possible or not. If you get any errors try generating a ssh key and submitting it to heroku.
 # ssh-keygen  
 # heroku keys:add ~/.ssh/id_rsa.pub  
Follow my previous post to create virtual hosts, also don’t forget to set facebook app id and app secret in “/etc/apache2/conf/extra/httpd-vhosts.conf” file under VirtualHost tag as below. You can these two from Facebook app site.
 <VirtualHost *:80>  
   DocumentRoot /home/ashish/savefromiad/xxxxxxxxxxxx  
   ServerName mycoolapp-dev.localhost  
   SetEnv FACEBOOK_APP_ID xxxxxxxxxxxxxxxxxx  
   SetEnv FACEBOOK_SECRET xxxxxxxxxxxxxxxxxxxxxxxxxxxxx  
 </VirtualHost  
When I tried accessing the virtual site I got a blank page. I tried searching on internet and got this error in apache error.log at “/var/log/apache2/error.log”.
 PHP Warning: require_once(sdk/src/facebook.php): failed to open stream: No such file or directory  
When checked the app directory I found that the php sdk was missing so I got that from their git repository.
and copied that under src/sdk of my app local directory.
Still I kept getting permission error so I changed the owner of the directory to www-data as below.
 # chown -R www-data .  
So the permission error vanished, please bear in mind that may have further repercussions but for now things worked for me. I got this help while setting up Joomla! locally so applied this here as well.
But the errors kept coming, this time like this one.
 Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension.  
So checked the php manual and from user notes installed curl and php extension as below.
 # sudo apt-get install curl libcurl3 libcurl3-dev php5-curl  
Even after this it didn’t worked so I restarted my laptop and lo!!! it worked.

Update:

Later I noticed that this local running is not same as on heroku.Will see how to resolve and add.

Update 2:

In the mean time you could try heroku eclipse plugin http://eclipse-plugin.herokuapp.com. It greatly eases the change, commit, and test phases. Off course you would be running your actual master code

Thanks for reading and thanks to guys for helping me out. Please don’t forget to share if you find this helpful.

via Blogger http://ashish-yadav.blogspot.com/2012/11/deploying-facebook-php-app-locally-on.html

Creating virtual hosts in apache2


Recently I was trying to create a facebook app and thought of creating virtual hosts on my machine where I possibly could test it. Here is the steps I took to create two virtual hosts on my Linux Mint.First install LAMP stack if you don’t have it already

 sudo apt-get install lamp-server^ -y  

(Don’t forget the caret ‘^’)

Now define the following in “/etc/apache2/conf/extra/httpd-vhosts.conf” file

 NameVirtualHost *:80  
If the above mentioned file does not exist create it.
Also make sure that “/etc/apache2/httpd.conf” has this line
 Include conf/extra/httpd-vhosts.confconf  
NameVirtualHost needs to be all conf files only once so make sure that “/etc/apache2/ports.conf” has got it commented out.
 #NameVirtualHost *:80  
Now create the definition of virtual hosts like below.
 NameVirtualHost *:80  
 <VirtualHost *:80>  
    DocumentRoot "/var/www"  
    ServerName localhost  
  </VirtualHost>  
 <VirtualHost *:80>  
   DocumentRoot "/var/www/mysite"  
   ServerName mysite.localhost  
 </VirtualHost>  
One also need to create the entry in “/etc/hosts” like this.
 127.0.0.1    localhost  
 127.0.0.1    mysite.localhost  
Now you should be able to test your sites.
Thanks for reading and much credit goes to guys on internet for helping out specially on stackoverflow.com.

via Blogger http://ashish-yadav.blogspot.com/2012/11/creating-virtual-hosts-in-apache2.html