Search This Blog

Saturday, December 17, 2011

TOP ANDROID APPLICATION

Elimatta:

         This cool Android App is a location based blogging tool that supports posting by individuals in the same geographic area, whereas outsiders can only review the blogs without adding their own. This could come handy to different users like fishermen who can notify other fishermen of fish shoals or boast about their day's catch.

Metosphere:

      This is a Android based web browser that allows you to view virtual objects around your physical location like messages, emergency, news, events, alerts, games, reviews.

TwitterDroid: 

       It is an Android based Twitter client that lets you to share your twitters online and read what others have to tweet about. You can also use the sleek blacka Android theme for your TwitterDroid.

Parallel Kingdom: 

        Did you think the Android lacked a GPS based game app for the avid gamers, then think again for Parallel Kingdom is one of the few GPS based role playing games built for the Android. The game uses the real world as the base for the real world giving users the option to attack, hug, dance or team up with anyone around them.

City Audioguides: 
         
           Attempting to enliven your travelling experience the City Audioguide provides up to date detailed audio info on any historical place, popular tourist destination you are visiting. 

KudoStar: 

            KudoStar is a handy social networking Android based application that allows you to link and rate your contacts with your favourite locations and assign a positive or negative Kudo score to this combination. The data so compiled can then be spread across the social networking world by using Facebook's F8 or Google's open social platforms.



This is a small but not an exhaustive list of popular Android applications available on the online Android market. Rest assured come the second half of 2009 when we can witness launch of many Android based mobile phones and consequently a plethora of Android apps. Be ready to be spoilt for choice then.

Give preferences in the screen

First of all create the preference.xml file and enter in it.


<?xml version="1.0" encoding="utf-8"?>
<!-- This file is /res/xml/flightoptions.xml -->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:key="using_categories_in_root_screen"
android:title="Categories"
android:summary="Using Preference Categories">
<PreferenceCategory
xmlns:android="http://schemas.android.com/apk/res/android"
android:key="meats_screen"
android:title="Meats"
android:summary="Preferences related to Meats">
<CheckBoxPreference
android:key="fish_selection_pref"
android:title="Fish"
android:summary="Fish is great for the healthy" />
<CheckBoxPreference
android:key="chicken_selection_pref"
android:title="Chicken"
android:summary="A common type of poultry" />
<CheckBoxPreference
android:key="lamb_selection_pref"
android:title="Lamb"
android:summary="Lamb is a young sheep" />
</PreferenceCategory>
<PreferenceCategory
    xmlns:android="http://schemas.android.com/apk/res/android"
android:key="meats_screen"
android:title="Foods"
android:summary="Preferences related to Meats">
<CheckBoxPreference
android:key="tomato_selection_pref"
android:title="Tomato "
android:summary="It's actually a fruit" />
<CheckBoxPreference
android:key="potato_selection_pref"
android:title="Potato"
android:summary="My favorite vegetable" />
</PreferenceCategory>
</PreferenceScreen>


And make a java file preferencescreens.java of the following.


package org.apache.android;


import android.os.Bundle;
import android.preference.PreferenceActivity;


public class preferencescreens extends PreferenceActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference);
}
}

Now make an main.xml file



<?xml version="1.0" encoding="utf-8"?>
<!-- This file is /res/layout/main.xml -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:text="" android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>


make a main.java file


package org.apache.android;


import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TextView;


public class mainActivity extends Activity {



private TextView tv = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tv = (TextView)findViewById(R.id.text1);
setOptionText();
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.mainmenu, menu);
return true;
}


@Override
public boolean onOptionsItemSelected (MenuItem item)
{
if (item.getItemId() == R.id.menu_prefs)
{
Intent intent = new Intent().setClass(this, preferencescreens.class);
this.startActivityForResult(intent, 0);
}
else if (item.getItemId() == R.id.menu_quit)
{
finish();
}
return true;
}


@Override
public void onActivityResult(int reqCode, int resCode, Intent data)
{
super.onActivityResult(reqCode, resCode, data);
setOptionText();
}




private void setOptionText()
{
SharedPreferences prefs = getSharedPreferences("Sharedpreference", 0);
String option = prefs.getString(this.getResources().getString(R.string.selected_flight_sort_option),
this.getResources().getString(R.string.flight_sort_option_default_value));
String[] optionText = this.getResources().getStringArray(R.array.flight_sort_options);
tv.setText("option value is " + option + " (" + optionText[Integer.parseInt(option)] + ")");
}
}

Thursday, December 1, 2011

ADD ELEMENT IN THE LIST AND REMOVE IT BY CLICKING IT

First of all make an XML file called listadapter.xml file and insert the following

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:layout_width="230dp" 
android:layout_height="wrap_content" 
android:id="@+id/myEditText"/>
<Button android:text="Add"
android:id = "@+id/Add"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background = "@drawable/button_shape"
/>
</LinearLayout>
<ListView
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:id="@+id/MyListView">
</ListView>
</LinearLayout>



AND create the class file called ListAdapter.java and insert the following into it



import java.util.ArrayList;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

import android.widget.Toast;


public class ListAdapter extends Activity {
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       Toast.makeText(ListAdapter.this, "Redirecting to List Activity", 400000).show();
     //  TextView textview = new TextView(this);
     //  textview.setText("This is the Artists tab");
       setContentView(R.layout.listadapter);
       Button bt = (Button)findViewById(R.id.Add); 
       ListView lv = (ListView)findViewById(R.id.MyListView);
       final EditText myEditText= (EditText)findViewById (R.id.myEditText);
       final ArrayList<String> videolinks = new ArrayList<String>();
       final ArrayAdapter<String> aa;
       
       aa= new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,videolinks);
       
       lv.setAdapter(aa);
       
       bt.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(myEditText.getText().length() != 0)
{
videolinks.add(0, myEditText.getText().toString().trim());
aa.notifyDataSetChanged();
myEditText.setText("");
}
}
       });
       lv.setOnItemClickListener(new OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> arg0, View arg1,int arg2, long arg3) {
// TODO Auto-generated method stub
AlertDialog.Builder ad  = new AlertDialog.Builder(ListAdapter.this);
ad.setTitle("Delete?");
ad.setMessage("Are you sure you want to delete " + arg2);
final int positionToRemove = arg2;
ad.setNegativeButton("Cancel", null);
ad.setPositiveButton("Ok", new AlertDialog.OnClickListener() {
public void onClick(DialogInterface dialog, int which) 
{
               videolinks.remove(positionToRemove);
               aa.notifyDataSetChanged();
       }
});
ad.show();
}
});
  }
}


How to call Android contacts list?

Hi this is very import concept to Read Existing Contacts from Your Emulator or Device

There are three steps to this process.


1) Permissions
Add a permission to read contacts data to your application manifest. 

Android:name="android.permission.READ_CONTACTS"/>

2) Calling the Contact Picker

Within your Activity, create an Intent that asks the system to find an Activity that can perform a PICK action from the items in the Contacts URI.

Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);

Call startActivityForResult, passing in this Intent (and a request code integer , PICK_CONTACT in this example). This will cause Android to launch an Activity that's registered to support ACTION_PICKon the People.CONTENT_URI, then return to this Activity when the selection is made (or canceled).

startActivityForResult(intent, PICK_CONTACT);

3) Listening for the Result

Also in your Activity, override the onActivityResult method to listen for the return from the 'select a contact' Activity you launched in step 2. You should check that the returned request code matches the value you're expecting, and that the result code is RESULT_OK.

You can get the URI of the selected contact by calling getData() on the data Intent parameter. To get the name of the selected contact you need to use that URI to create a new query and extract the name from the returned cursor.

@Override 
public void onActivityResult(int reqCode, int resultCode, Intent data) {
                   super.onActivityResult(reqCode, resultCode, data); 
                   switch (reqCode) { 
                           case (PICK_CONTACT) : 
                                 if (resultCode == Activity.RESULT_OK) 
                                {
                                        Uri contactData = data.getData(); 
                                        Cursor c = managedQuery(contactData, null, null, null, null);
                                        if (c.moveToFirst()) 
                                       { 
                                 String name = c.getString(c.getColumnIndexOrThrow(People.NAME));
                                 // TODO Whatever you want to do with the selected contact name. 
                                      } 
                                 }
 break; 
}

}    
Home Screen If No Contacts Contacts