Run C program on Android Device – C Programming Tutorial

In this c programming tutorial we are going to see How To run C programs on your android phone you need “Terminal IDE” android app installed on your phone. Click here to install this app from play store.

Once you have installed Terminal IDE, open it and now will see six buttons there on screen, from those buttons choose Install System, and then scroll down check the checkbox Overwrite ALL and then click Install System. By doing this some basic C / binary system files get installed in your phone (in applications private memory)

Next Step is to install gcc on your phone; it will take up to 70MB memory on your phone, to install gcc, go to the main options in app then terminal screen will be opened, type install_gcc on terminal and hit enter from your android keyboard now gcc is installed on your mobile.

To test it type cd  ~/system/src/c_examples/chello/ on terminal and hit enter , this will switch the current working directory of terminal to ~/system/src/c_examples/chello/. This directory already contains one test program. To see the file name and then open that c program type ls and then type cat hello.c  , now you can see it is a simple c program to print some message on the screen.

To compile this simple c program type terminal-gcc hello.c  and then to run the program type ./a.out , now you can see the output of this program on your screen.

You can also create your own c program and run using this app, just remember to use cd command to switch your current working directory to point to place where your program is present. You can even create and run java programs, shell script using this android application. For more details click on Help button from main screen of app and then select Tutorials, you can get all details about how to use this application.

Terminal IDE android app is available under GPLv2, code is available at:

Thank You for reading 🙂

Comparing two locations for accuracy in Android

If you are developing a android application which uses android Location Service and you need to find best estimated location by comparing two locations, where one location is the currently obtained location and other is from the location fix then this post contains answer to your question. The below mentioned code contains a method isBetterLocation which will compare two locations and will return true if current location is more accurate than location fix. You might expect that the most recent location fix is the most accurate. However, because the accuracy of a location fix varies, the most recent fix is not always the best.

isBetterLocation method follows following criteria for choosing location fixes, you vary this criteria depending on the use-cases of the application and field testing.

  • Check if the location retrieved is significantly newer than the previous estimate.
  • Check if the accuracy claimed by the location is better or worse than the previous estimate.
  • Check which provider the new location is from and determine if you trust it more.

Code for setting webview in android