Friday 31 January 2014

Update ADT


  1. Open Eclipse and go to the Help menu
  2. Install New Software
  3. Add Location: https://dl-ssl.google.com/android/eclipse/
  4. after loading you should get Developer Tools and NDK Plugins
  5. check both if you want to use the Native Developer Kit (NDK) in the future or check Developer Tool only
  6. click Next
  7. click Finish

Thursday 23 January 2014

Using Subclipse with Eclipse and configuring for Google Code

Assuming that you have installed and are using Eclipse.

  1. Go to Eclipse Help menu and click on "Install New Software"
  2. Install Subclipse:
    Add the following site for subclipse
    http://subclipse.tigris.org/update_1.10.x/
  3. Select both "Subclipse" and "SVNKit" from the names which appear after adding the subclipse link
  4. Click Next, accept conditions and let eclipse download and install subclipse
  5. Now restart Eclipse after the installation
    Subclipse will be ready to use now
  6. Go to "preferences" under the windows menu
  7. Go to "Team" in the left menu and then select "SVN" sub-menu
  8. In the "General SVN Setting" select Team and "SVN" sub-menu
    Select SVNKit (Pure Java)--- in the "SVN interface" drop-down menu
Next step is to connect subclipse with google code

First we have to create a project. Instructions for creating a project can be found on
Creating Project on Google Code

Once a project has been created on the Google Code, Subclipse has to be connected to the project.


  1. Go to Eclipse, Click on "Windows" menu, "Show View" and select "Other"
  2. Select "SVN' and "SVN Repositories" and click OK.
  3. Right Click in the "SVN Repositories" tab and choose "New" - "Repository Location"
  4. "Add SVN Repository" window opens.
  5. Go to the Source tab and under Checkout you will find your svn checkout URL
  6. For the Location URL, give your URL which should be like  https://your_url.googlecode.com/svn/trunk
  7. In my case the URL is "https://agent-desktop.googlecode.com/svn/trunk" for the project which was created in Creating Project on Google Code post. Click Finish after providing the URL
  8. After Finishing you will be asked for the username and the password
    this password can be found on project home page under the SVN tab. Search for the link googlecode.com password
  9. Under the Source -> Checkout, Click the link (googlecode.com password) and save the generated password.
  10. Now the Subclipse is connected to the Google code
Next Step is to Commit your project code 

Follow instructions for committing code on Google Code project repository. 





Committing your Eclipse project to Google Code hosting

We are assuming that:

  1. Link ->You have created a project on Google Code
  2. And you have connected Subclipse with Google Code

If you have just created the project on Google code and connected Subclipse. Visit your "Source" tab (on Google Code your project home page) and then "Browse". Yet there is nothing. In order to send the project from your computer to Google Code repository it has to be committed. 

If this is the first time you are going to commit your code to the repository then
  1. Go to Package explorer in Eclipse
  2. Right click your project and select "Team" and "Share Project"

3. Select SVN and click Next

4. Check "Use existing repository location", select the repository that you have created and click Next
5. Press Next Next and on asking for password provide the password which is under "Source" tab of your project repository. Click googlecode.com password 
It will take you to the window where you can see your user name and password.

NOTE: Remember to change the username as well. Provide the one that is written in the repository (Maybe your email ID)

After the above first time (one time) process, follow these steps to commit your code to the repository:
  1. Go to Package explorer in Eclipse
  2. Right click your project and select "Team" and "Commit"
  3. A Commit window opens. Add a comment e.g added feature bla bla
  4. In the same Commit window the changes portion in the bottom shows the files that have been changed in your project since the last commit. If its the first time then everything will be displayed.
  5. Select or deselect whatever you want to send / not sent to the repository.
  6. One can choose not to commit the bin files
  7. Press OK
  8. Now go to the repository on the Google code project. Browse the source and your project will be uploaded

Creating and Hosting project on Google Code

Google provides free hosting for open source projects. Following are the steps to get started with the Google code project hosting:

  1. Go to Project Hosting Main Page
    Sign in with your Gmail account

  2. Here one can search through different projects which are already running and some can be joined as well. (one can use this if interested in working with a project which is already there). We will create our own project
  3. Go to Create New Project Page
  4. Provide Project name. In my case it is Agent Desktop
    Provide a name with lower case characters. Project name becomes the part of your project's URL
  5. Provide Summary and Description
  6. Choose "Subversion" for version control system
  7. For guidelines on how to choose licence and version control system visit
    http://opensource.org/licenses/category
    https://code.google.com/p/support/wiki/ChoosingAVersionControlSystem
  8. Further instructions can be found on
    https://code.google.com/p/support/wiki/GettingStarted
  9. Click "Create Project" and your project is created.
  10. Go to project and select the source tab. Here a link is mentioned for SVN checkout which should be like http://your-project-name.googlecode.com/svn/trunk

Sunday 12 January 2014

Android: Display a list dialog box

Following program will display a dialog box containing a list of items.
Different operations can be performed on the items present in the list by implementing the onClick section.

private void showListDialog(ArrayList<String> list)
{
int l = list.size();
final CharSequence[] items = new String[l]; // not a good way
for (int i = 0; i < l; i++)
items[i] = list.get(i);

final AlertDialog.Builder builder = new AlertDialog.Builder(ActivityName.this);
builder.setTitle("List Dialog");

builder.setItems(items, new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int item)
{
// perform some function on item being clicked
}
});

AlertDialog alert = builder.create();
alert.show();
}





Android: Changing application name in eclipse

Change the "Android:label" field in the application node in AndroidManifest.xml.

'android:label="@string/app_name"' can be found in
/res/values/strings.xml

Definition for string app_name:
<string name="app_name">APP NAME</string>

Saturday 11 January 2014

Android: Using SQLite Manager plugin in Eclipse

If SQLite is used while developing Android applications, database structure and data can be checked within Eclipse.

Follow these steps:

  1. Go to DDMS perspective
  2. Select -> data-> data-> package name-> databases (the table and data cannot be seen without the plugin)
  3. Download the jar file from here into eclipse/dropins folder
  4. Restart Eclipse
SQLite managers window opens by clicking the icon pointed by the arrow.


The structure of the database can be viewed in DataBase Structure tab and the data can be viewed in the browse data tab.

Android: Get boolean value from the database

Kindly read about SQLite datatypes.
Here is how can we retrieve boolean value

           try
{
String query = "Select 'check_in_time', 'total_hours', 'active' from hours where job_title = '" + taskName + "'";
cursor = adtDB.rawQuery(query, null);
while (cursor.moveToNext())
{
long checkInTime = cursor.getLong(0);
long totalHours = cursor.getLong(1);
boolean active = cursor.getString(2).equalsIgnoreCase("TRUE");
}
}
catch (Exception e)
{
Utils.println(e.getMessage());
}
finally
{
if (cursor != null) cursor.close();
close();

Thursday 9 January 2014

Android: ListView Example

package com.adt.app;

import adapters.HoursListAdapter;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ListView;
import database.ADTDBHelper;

public class HoursListActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{ // TODO
super.onCreate(savedInstanceState);
setContentView(R.layout.hours_list);
ADTDBHelper db = new ADTDBHelper(this);
HoursListAdapter adapter = new HoursListAdapter(this, db.getHours());
ListView listView = (ListView) findViewById(R.id.hours_lv);
listView.setAdapter(adapter);

ImageButton homeBtn = (ImageButton) findViewById(R.id.header_home);
homeBtn.setOnClickListener(this);
}

@Override
public void onClick(View v)
{
if (v.getId() == R.id.header_home)
{
Intent i = new Intent(this, ADT.class);
startActivity(i);
}
}
}

Imran Khan in my View .... A Situation before Election.




Situation is getting worse day by day and everyone is not only worried about the ever increasing prices of electricity, petrol, gas but also mourn about unavailability. The situation is panic . Pakistan is  losing its integrity all over world due to memo case and many other such events ……. Everyone is now looking towardAlmighty Allah to help them come out of this situation and send a MASEEHA to help all get out of chaotic situation.
Meanwhile Imran Khan comes up with great JALSA in Lahore and had become in flashlight. Media is giving coverage of every second and boasting Imran as the only HOPE of the nation. We can easily get an insight about the popularity of Great Cricketer-come-Politician by simply watching around us, in markets, schools, colleges, universities, bus stands. Everyone is discussing about politics and taking Imran as the only Hope of dying nation as people of  Pakistan have tested all faces twice or thrice and are now fed up of all they want change and Imran have come up as a strong candidate for CHAIR. Youth is showing their confidence and enthusiasm and is active to support him. And the graph of popularity is going up day by day.
Earlier we have seen Imran struggling over the years to establish him in nations politics and had support from youth, the youth who has seen him holding the world cup for them and bringing pride to Pakistan, but he could not get any break through, we have also seen him committing some mistakes and hurting his supporters but that is PAST.
Well Imran was in discussion from the time when he has came out to make Shoukat Khanum Cancer hospital and people from every age of life supported him . But no one knew that one day he will again unite this nation and will drive them.
After coming to politics he struggled a lot in last 15 years, he fought bravely stood before others and tried to put his point of view, but was not that successful as he just had the support of youth that has nothing to do with politics at that time. But now the youth is seemed to be in main stream and time will show what change they can bring in national politics.
Politics in Pakistan is I will say a family politics …. There are just few faces with 2, 3 parties and come after one another….so v could not see any change until any dictator comes and take charge. All faces are now exposed all the nation have tried and tested them all one by one, all were desperate about ongoing situation.
After giving an entry with tsunami in Lahore Imran khan has increased enthusiasm of public in politics and has become an increasing threat for existing parties who don’t even bother to think about him as a politician. All were busy confirming their positions in establishment for next elections. But all of the sudden whole scenario has change after Lahore tsunami. Politicians and establishments are restless not only by increasing popularity of Tehreek-e-Insaaf but also about their key party members leaving them and joining hands with Imran Khan.
Long after Zulfiqar Ali Bhutto Imran have brought out educated people who have never voted and was not interested in politics any more. Now people from all walks of life are out to support Imran as he is only Hope for Nation now. He has a charisma in his personality that what he decides people follow him blindly. This is a big success for him as half the work is done.Now we are waiting to see if he can stir the minds and hearts of people in Quetta and have a bewitching effect on them that they blindly follow him and support him in coming elections.
After hearing him I looked on him as a serious and cool minded Politian as he does not shows much enthusiasm in his speeches as we are familiar with. He has put forward himself as a strong personality over the years and man of determination and the way he have brought political rivals under one umbrella shows his sense of politics. He is a visionary man. Now he is here to eradicate plague of corruption from society and provide INSAAF on every door step.
International media is claiming that IK have caught sight and fame of people due to the failure of Zardari’s policies...and also attracted people with his opinion against America and drone attacks.
Let us hope we will have a fair election because it is the only way that will show clear picture what people of Pakistan are thinking and feeling now, and wait to see what happens in next elections because we also have seen that number in rallies does not actually confirms your position in establishment but keeping in view the media reports he is most favorite candidate for next elections as most of the Pakistani living in or abroad are fully supporting him.
Let’s see who will come next and with what…..whether he will stick to his promises with public or deviate and deceive nation as its common practice since ages.
It will be a great Challenge for Revolutionary Leader to bring change and keep up with hope of people as the situation in Pakistan is far worst then anyone can imagine.