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

Saturday, November 26, 2011

Tabs in android programming

First of all make an layout of this Tab Activity

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#181818">
    <!-- LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp"-->
        <RelativeLayout
        android:layout_height="fill_parent"
        android:layout_width="fill_parent">
         <!--  HorizontalScrollView 
        android:id="@+id/horizontalScrollView1" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        -->
        
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            
            />
            <!--   /HorizontalScrollView-->
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp" />
            </RelativeLayout>
    
</TabHost>




Then JAVA file of the Tab is below :


package com.blacky.TabActivities;


import com.blacky.basictutorial.R;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;


public class TabtryActivity extends TabActivity {
    


/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tabactivity);
        
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;   // Resusable TabSpec for each tab
        Intent intent;   // Reusable Intent for each tab
        Resources res = getResources();
       
        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, Tab1.class);


        // Initialize a TabSpec for each tab and add it to the TabHost
        spec = tabHost.newTabSpec("artists").setIndicator("Artists",res.getDrawable(R.drawable.ic_drawable_changes))
                      .setContent(intent);
        tabHost.addTab(spec);


        // Do the same for the other tabs
        intent = new Intent().setClass(this,Tab2.class);
        spec = tabHost.newTabSpec("albums").setIndicator("Albums",res.getDrawable(R.drawable.ic_drawable_changes))
                      .setContent(intent);
        tabHost.addTab(spec);


        intent = new Intent().setClass(this, Tab3.class);
        spec = tabHost.newTabSpec("songs").setIndicator("Songs")
                     .setContent(intent);
       tabHost.addTab(spec);


       tabHost.setCurrentTab(0);
    }
}


According to that make the xml file of all the tabs separately and put the contant view in the java file of all the tab.

Tuesday, February 15, 2011

Devlopment in android

Android is an operating system based on Linux with a Java programming interface. It provides tools, e.g. a compiler, debugger and a device emulator as well as its own Java Virtual machine (Dalvik Virtual Machine - DVM). Android is created by the Open Handset Alliance which is lead by Google.
Android uses a special virtual machine, e.g. the Dalvik Virtual Machine. Dalvik uses special bytecode. Therefore you cannot run standard Java bytecode on Android. Android provides a tool "dx" which allows to convert Java Class files into "dex" (Dalvik Executable) files. Android applications are packed into an .apk (Android Package) file by the program "aapt" (Android Asset Packaging Tool) To simplify development Google provides the Android Development Tools (ADT) for Eclipse . The ADT performs automatically the conversion from class to dex files and creates the apk during deployment.
Android supports 2-D and 3-D graphics using the OpenGL libraries and supports data storage in a SQLite database.
Every Android applications runs in its own process and under its own userid which is generated automatically by the Android system during deployment. Therefore the application is isolated from other running applications and a misbehaving application cannot easily harm other Android applications.

Friday, February 11, 2011

hiiii

JAVADOCS.org

best site of java
it covers all the packages,classes,exceptions

Tuesday, February 8, 2011

Hello friends

Hi i am arpit patel from Gandhinagar institute of technology.
I am pursuing IT from it.
I am a programmer.
I am here to share the materials and websites to give you the proper guidence of the JAVA basic and help you to program in JAVA