Monday, August 27, 2012

GitHub for Dummies - From Command Line

GitHub is a free cloud based version control system. Its extremely powerful but at the same time is a little daunting to use for the first time.
Here is a small guide to easily use GitHub without much fuss! 
Step 1: Create an account on GitHub  (https://github.com/)
  If you are ok with your code being public then GitHub is free to use else it will cost you. 
  
Step 2:  Create a new repo or repository on GitHub. Name it test.
Step 3: Download GIT tools from the site and install. 
Step 4: In your working directory which you want to push to git do the following: 
git init  (initializes your local directory to be a git compliant directory)
git add *  (adds all files in current directory and sub directories to git local repo)
git commit -m "Initial Commit" (Commits all added files to local repo first)
git remote add origin https://github.com/USERNAME/REPONAME.git (add a remote git reference for github repo)
  Alternatively you can add
git remote add origin git@github.com:USERNAME/REPONAME.git
git push -u origin master (Push all the committed files which will be in master repo by default into the remote site you added called origin)
That's it done. Go online and see your code in all its glory!

After this for incremental updates just do this:
git add *
git commit -m "Updates"
git push -u origin master (This will add whatever was changed).

You can see what will be committed using git status command.

Friday, August 5, 2011

Small Tutorial on Creating a transparent activity


Sometimes, we need an activity to some processing but we need not necessarily have a UI.
For this, you can do just not do a setContentView() call. This will show up an activity with the default theme applied.

But, what if you need a transparent activity? It should be showing what is behind it and still do some stuff.

For that, follow this tutorial:
1. Create an Android project in eclipse.
2. Let us create an Activity called TransparentActivity.
3. Then, we need to create a transparent theme.



<resources>
  <style name="Theme.Transparent" parent="android:Theme">
   <item name="android:windowIsTranslucent">true</item>
   <item name="android:windowBackground">@android:color/transparent</item>
   <item name="android:windowContentOverlay">@null</item>
   <item name="android:windowNoTitle">true</item>
   <item name="android:windowIsFloating">true</item>
   <item name="android:backgroundDimEnabled">false</item>
  </style>
</resources>


4. Add the above code to styles.xml under res/values folder.
5. Then, in your AndroidManifest.xml apply the theme "Theme.Transparent" to this activity like:


6. That's it you are done. This activity will be transparent and not display anything.
7. Additionally, you can call requestWindowFeature(Window.FEATURE_NO_TITLE) to remove the title bar.

Sometimes, you may need to display a dialog on this activity. Say, you are processing something and want to show the user the progress. For this, you can create a ProgressDialog and show it.
But, in case of a transparent activity, it displays an outer box for the dialog.

To get rid of this:
In your onCreateDialog or the place where you are initializing the dialog do the following:


@Override
protected Dialog onCreateDialog(int id) {

switch(id) {
case 100:
dialog = new ProgressDialog(this, ProgressDialog.STYLE_SPINNER);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setMessage("Message");
//The below line does the trick!!
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
return dialog;
}
return super.onCreateDialog(id);
}


That's it for this tutorial. Check this out :)

How to Increase Memory for Android Emulator



This is an issue often faced when setting up the Android Emulator for the first time.
Usually it runs nicely for sometime and then starts giving INSTALL_FAILED_INSUFFICIENT_STORAGE error.

It does not depend on the application size also. Usually, if we restart the emulator the problem goes away but only temporarily. To properly solve this, we need to increase the emulator's memory size.

To do that follow this thread on stackoverflow.com here.

Saturday, February 28, 2009

Android Debug Bridge

The Android Debug Bridge is the Android debug interface for assisting in developing applications. It has many useful functions like installing applications, opening shell etc. Let us have a brief look at the various functions supported by ADB.


1. adb install - Installs applications onto the Android system.

2. adb uninstall -k - Uninstalls the specified package from Android system. The -k option means to preserve the data and cache directories.

3. adb push - Pushes files from the local computer path onto Android remote path.

4. adb pull - Pulls files from the remote Android path to local computer path.

5. adb shell - Opens the shell on the currently running emulator.

Saturday, February 7, 2009

What is Android?

Android is an open source Software stack for mobile devices built upon the linux OS. It was developed by Google and the Open Handset Alliance. It is the world's first mobile OS which exposes the framework level APIs in Java. All the applications are developed in Java for Android. Since, Java is an object oriented and simple to learn programming language, Google hopes more people will be interested to jump into the Android development bandwagon.

Below is the architecture of Android*.


All the boxes marked in blue are built in Java. The other down layers are in the native C/C++. The ones marked in red are part of the linux kernel. There is a JNI layer between the libraries and Java components to enable application development in Java. In Android there is no privileged APIs which only some companies can use. All APIs are open for all developers. This truly brings out the power of Android to the open.

Let us answer more basic questions on Android in future posts...

Welcome to Android :-)

* - Picture courtesy Google.