Monday 17 February 2014

Android Application Structure

The package explorer is in the left side of the Eclipse IDE
It contains Projects and its associated files
The first one is src folder
1 - src : this folder contains the packages and the java classes used in the application, we can include more than 1 packages and java classes to the src folder
2 - gen : this folder is automated generated java files it contains the all id of the declared variables and objects
3 - Next is the build version of the application and associated private libraries and user defined libraries
4 - bin : This folder contains the output files of the project Eg dex files,resource files, Apk files
5 -  libs : this folder contains the library files used in the project
6 - res : this folder contains the layout file which means the user interface design and the resources like pictures and music and other files
6.1 - drawables this is the media files and other files used in the application and the images are loaded in their preferred folder
  for lower density devices the low dimension image must included in drawable-ldpi folder
  for medium density devices the medium dimension images must included in drawable-mdpi folder
  for high density devices the high dimension images must included in drawable-hdpi folder
  for xlarge density devices the xhdpi dimension images must included in drawable-xhdpi folder
6.2 - layouts : this folder contains the UI design files and the other layout files.
6.3 - menu : this folder contains the menu  XML files used to control the menus used in the application.
6.4 - values : this contains the XML files used to store the string values used in the application
7 - Manifest.xml - this file is the main file of the application the file contains the application permissions and activity registrations and services

Now you can create an application Thank you....... :-)
If you have any doubts please mail to me ribindasmayilpeeli@gmail.com please include subject to from blog

Creating first Android Application

Open the Eclipse IDE
Select a workspace for saving the project and click ok
When opens the Eclipse 
Select File ->New -> Android Application Project
Enter Application name and Project name
dont forget to change package name
Select Minimum SDK - its better to choose low sdk version
Select Target SDK - its your applications required version
Select compile with - its the API level selector select appropriate api

And click next
From this window you can select the Applications icon
And click next

Select Black Activity and Click next
Enter the MainClass Name And click next
This is your application Structure

Then run your emulator



And click Run in IDE

You will get output









Wednesday 12 February 2014

Start Android Development

Hi friends Do you know what is android????
Android is a mobile operating system. Android is used in Smartphone devices
Android first release is Android 1.0 on 23 September 2008 (API Level 1)
Android 1.1 on 9 February 2009 (API Level 2)
Android 1.5 Cupcake on 30 April 2009 (API Level 3)
Android 1.6 Donut on 15 September 2009 (API Level 4)
Android 2.0 Eclair on 26 October 2009 (API Level 5)
Android 2.0.1 Eclair on 3 December 2009 (API Level 6)
Android 2.1 Eclair on 12 January 2010 (API Level 7)
Android 2.2 Froyo on 20 May 2010 (API Level 8)
Android 2.3 Gingerbread on 6 December 2010 (API Level 9)
Android 2.3.3 Gingerbread on 9 February 2011 (API Level 10)
Android 3.0 Honeycomb on 22 February 2011 (API Level 11)
Android 3.1 Honeycomb on 10 May 2011 (API Level 12)
Android 3.2 Honeycomb on 15 July 2011 (API Level 13)
Android 4.0 Ice Cream Sandwich on 19 October 2011 (API Level 14)
Android 4.0.3 Ice Cream Sandwich on 16 December 2011 (API Level 15)
Android 4.1 Jellybean on 9 July 2012 (API Level 16)
Android 4.2 Jellybean on 13 November 2012 (API Level 17)
Android 4.3 Jellybean on 24 July 2013 (API Level 18)
Android 4.4 KitKat on 31 October 2013 (API Level 19)

First we need an IDE  to develop android app
the all development tool kit download from here Get the Android SDK
after downloading extract the zip file in to folder.
then open the eclipse folder double click the eclipse.exe file now the IDE will open
This is the IDE
then goto the window>preferences
then a window will appear in that window select android tab

Set the sdk location to the downloaded sdk folder then click apply and ok
Now your development tools are ready.
In this time you have only one development kit its android 4.4 kitkat . you have to download other sdk from internet
by clicking sdk manager icon in IDE
in the window you can select your sdk requirements and click install packages

At last we need a testing device called emulator(AVD). click the android virtual device icon
Create new virtual device(Emulator)
1. dont forget to add sd card memory.
2. allocate ram memory more than 512 mb.
3. tick snapshot.



Now you can start coding.   Happy Coding -:)

Friday 21 June 2013

Create Shortcut of your application on Startup in android

Hi friends this tutorial is for android developers those who want to create shortcut of their costume application on home screen
The Tutorial is Given below

Open your Launcher Activity
&
Create a Shared preference this to avoid the duplication of shortcuts

public class Splash extends Activity{

SharedPreferences preferences;
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);

preferences = PreferenceManager
                .getDefaultSharedPreferences(getApplicationContext());
        Editor editor = preferences.edit();

        boolean status = preferences.getBoolean("shortcut", false);
                if (status) {
                    } else {
            Intent shortcutIntent = new Intent(getApplicationContext(),
                    Splash.class);

            shortcutIntent.setAction(Intent.ACTION_MAIN);

            Intent addIntent = new Intent();

            addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
            addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Shortcutname"); //
            addIntent.putExtra("duplicate", false);
            addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
                    Intent.ShortcutIconResource.fromContext(
                            getApplicationContext(), R.drawable.ic_launcher));

            addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); //
            addIntent.putExtra("duplicate", false);
            getApplicationContext().sendBroadcast(addIntent);

            editor.putBoolean("shortcut", true);
            editor.commit();
        }

}
}


copy this code to your activity class and enjoy

Dont forget to add permission
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> 


Thank you

please comment here if any error occurs

Friday 31 May 2013

Sendig Email from our custome application with out using native application in android tutorial

Dear friends this is the tutorial for building Email sending application. It will allow sending Emails from our application
1. First create your new project 
2. And download all jar files from this link       
3. Paste this jar files to your project and right click all jar files go to build path and click add to build path
4. Then copy this code to your project this is my layout file

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/hello_world" />

    <Button
        android:id="@+id/mBtnSubmit"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="5dip"
        android:text="Send Mail" />

</RelativeLayout>



5. Now copy the Source code to your Activity class

import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button login = (Button) findViewById(R.id.mBtnSubmit);
        login.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                Properties props = new Properties();
                props.put("mail.smtp.host", "smtp.gmail.com");
                props.put("mail.smtp.socketFactory.port", "465");
                props.put("mail.smtp.socketFactory.class",
                        "javax.net.ssl.SSLSocketFactory");
                props.put("mail.smtp.auth", "true");
                props.put("mail.smtp.port", "465");

                Session session = Session.getDefaultInstance(props,
                        new javax.mail.Authenticator() {
                            @Override
                            protected PasswordAuthentication getPasswordAuthentication() {
                                return new PasswordAuthentication(
                                        "sender_email@example.com", "password");
                            }
                        });

                try {
                    MimeMessage message = new MimeMessage(session);
                    message.setFrom(new InternetAddress(
                            "
sender_email@example.com"));
                    message.setRecipients(Message.RecipientType.TO,
                            InternetAddress.parse("receiver_email@gmail.com"));
                    message.setSubject("Testing Subject");
                    message.setContent(
                            "Your text");

                    Transport.send(message);

                } catch (MessagingException e) {
                    throw new RuntimeException(e);
                }
            }
        });
    }
}


6. Include all permissions in your manifest file

  <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>



Now you can Run your project 
By clicking send button the content that you have written in the code will send to the specified gmail address

Thank you..............:-)

Please write reviews below if any problem occurs please write below or contact me ribindasmayilpeeli@gmail.com

Thank you once again.......:-)

Friday 29 March 2013

Qr code Reading On your Application example

To create your Qrcode reader You must download the Native zxing qrcode application source code its open source and you can use it anywhere download the source code and import to your workspace
 

And import the native android project into your eclipse and right click on the project as shown in the above picture and goto the project properties.there is a window will appear in that window tick the is library check box and press then the project is now as library project 


now you can use the library project into your application
And Create your qrcode reader project
And right click on your project
Select project properties 
in the window u click the add button
And the select the native library project and click ok



Then the library project will appear below the property window then click the ok button 
now you can access the all features in the native qrcode reader

this is my project
I created a project with name SCANNERMY  With class Name Scanning
and Write the code as shown below

package com.inzane.activitiy;

import com.inzane.scanner.R;


import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.widget.TextView;
import android.widget.Toast;

public class Scanning extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scanning);

Intent intent = new Intent("com.google.zxing.client.android.SCAN");
startActivityForResult(intent, 0);
}

public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_RESULT");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
Toast.makeText(this, contents,Toast.LENGTH_LONG).show();
// Handle successful scan
} else if (resultCode == RESULT_CANCELED) {
//Handle cancel
}
}
}
}


the layout is 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".Scanning" >

</RelativeLayout>

the Manifest.xml is

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.inzane.scanner"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="9" />

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.FLASHLIGHT" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
 

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.inzane.activitiy.Scanning"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.google.zxing.client.android.CaptureActivity"
              android:screenOrientation="landscape"
              android:clearTaskOnLaunch="true"
              android:stateNotNeeded="true"
              android:configChanges="orientation|keyboardHidden"
              android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
              android:windowSoftInputMode="stateAlwaysHidden">
              <intent-filter>
                <action android:name="com.google.zxing.client.android.SCAN"/>
                <category android:name="android.intent.category.DEFAULT"/>
              </intent-filter>
        </activity>


      
    </application>

</manifest>


And you can run your project

a toast will be appear in your application that is the qrcode scanning result 

Thank you