postheadericon copy file from Assets to SDcard in Android Example



Definition : 16. Create an application to read file from asset folder and copy it in memory card.


File Name : E16.java


package bsr.exa;

import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

postheadericon MediaPlayer Example in Android



Definition : 17) Create an application that will play a media file from the memory card.


File Name : E17Activity.java


package bsr.exa;

import bsr.exa.R;
import android.app.Activity;
import android.content.Context;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

postheadericon read file from sdcard in android example



Definition : 19) Create an application to read file from the sdcard and display that file content to the screen.


File Name : E19Activity.java


package bsr.exa;

import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;

postheadericon onTouchEvent Example in Android



Definition : Create an application to draw line on the screen as user drag his finger.


File Name : E20.java


package bsr.exa;

import android.app.Activity;
import android.os.Bundle;

public class E20 extends Activity {
/**  @author Bipin S Rupadiya , www.bipinrupadiya.blogspot.com
*
*
*   20) Create an application to draw line on the screen as user drag his finger.
     *
     *  */

postheadericon Android Sending SMS Example



Definition : Create an application to send message between two emulators


File Name : E21Activity.java


postheadericon Camera Example in Android



Definition: Create an application to take picture using native application


File Name :


package bsr.exa;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class E22Activity extends Activity {
    /** Called when the activity is first created. */
    ImageView iv;
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        iv=(ImageView)findViewById(R.id.imageView1);
        Button b =(Button)findViewById(R.id.button1);
        b.setOnClickListener(new OnClickListener() {

public void onClick(View arg0) {
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i, 0);
}
});
    }
protected void OnActivityResult(int requestCode,int resultcode,Intent data)
{
Bitmap bm=(Bitmap)data.getExtras().get("data");
iv.setImageBitmap(bm);
}
}

File Name : AndroidManifest.xml


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="bsr.exa"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="8" />
    <uses-permission android:name="android.permission.CAMERA"></uses-permission>

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".E22Activity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>





postheadericon MediaStore.Images Content Provider example in android



Definition: 23) Create an application to pick up any image from the native application gallery and display it on the screen


File Name : EX23.java


package bsr.exa;

import java.io.File;
import java.io.FileInputStream;


import android.app.Activity;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.provider.MediaStore.Images.Media;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class E23 extends Activity {
/**
*
* @author Bipin S Rupadiya , www.bipinrupadiya.com
*
* 23) Create an application to pick up any image from the native application gallery and display it on the screen.
*
* Note :  First add a file to sdcard and check with media scanner (from dev tools)
**/
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);
        try
        {
       
            String[] projection={Media.DISPLAY_NAME, Media.DATA, Media.SIZE};
            Cursor c=managedQuery(Media.EXTERNAL_CONTENT_URI, projection, null, null, null);
            ImageView ivImage=(ImageView)findViewById(R.id.myImg);
            File file = null;
            String imgName = null ;          
           
            if(c.getCount()>0)
            {
                while(c.moveToNext())
            {
              file=new File(c.getString(1)); //after completing loop, it take last image from native Gallery to display.
            imgName=c.getString(0);
              }
        c.close();
        FileInputStream fis=new FileInputStream(file);
        byte[] buffer=new byte[fis.available()];
        fis.read(buffer);
        Bitmap bm=BitmapFactory.decodeByteArray(buffer, 0, buffer.length);
       
        TextView txtTitle=(TextView)findViewById(R.id.txtTitle);
        txtTitle.setText(imgName.toString());
        ivImage.setImageBitmap(bm);
            }
        }
        catch(Exception e)
        {
        Toast.makeText(E23.this, "Error: "+e, Toast.LENGTH_LONG).show();
        }  
    }
}

File Name :AndroidManifest.xml


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      android:versionCode="1"
      android:versionName="1.0" package="bsr.exa">
    <uses-sdk android:minSdkVersion="8" />

    <application android:label="@string/app_name" android:icon="@drawable/icon">
        <activity android:label="@string/app_name" android:name="E23">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>





postheadericon Step by Step Android Examples for Beginners




This Post “Step by step Android Examples for Beginners” is the result of many request I got through the web. Here, I would like to provide, the step by step example on Android which can be helpful to the one who have just started the journey of Mobile Application Development using Android as Beginners. 


postheadericon Image Gallery Widget Example in Android



postheadericon GridView Example in Android




postheadericon Switch Example in Android



postheadericon RatingBar example in Android




postheadericon ToggleButton example in Android



postheadericon How to set text style for TextView using Typeface in Android



postheadericon How to access Resource String in Android



MainActivity.java

package com.example.r_stringdemo;

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


public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

String nm=getApplicationContext().getString(R.string.un);
if(nm.equals("bipin"))
{
Toast.makeText(getApplicationContext(), "True", Toast.LENGTH_LONG).show();
}
}
}

postheadericon Simple ListView Example in Android



postheadericon Android Versions List with Code Name and API



Version Code Name API Level
Android 1.0 alpha 1
Android 1.1 beta 2
Android 1.5 Cupcake  3
Android 1.6 Donut 4
Android 2.0 Eclair  5
Android 2.0.1 Eclair  6
Android 2.1 Eclair  7
Android 2.2–2.2.3 Froyo 8
Android 2.3–2.3.2 Gingerbread 9
Android 2.3.3–2.3.7 Gingerbread 10
Android 3.0 Honeycomb  11
Android 3.1 Honeycomb  12
Android 3.2 Honeycomb  13
Android 4.0–4.0.2 Ice Cream Sandwich  14
Android 4.0.3–4.0.4 Ice Cream Sandwich  15
Android 4.1 Jelly Bean 16
Android 4.2  Jelly Bean 17
Android 4.3 Jelly Bean 18
Android 4.4 KitKat  19
Android 5.0 Lollipop 21
Android 5.1 Lollipop 23
Android 6.0 Marshmallow 22




postheadericon GTU WTAD Important Questions Bank


Unit-1 HTML and JavaScript 

  • Give DOM hierarchy? Explain properties, methods and events for text element of Html form
  • What is JavaScript? Explain the advantages of JavaScript.
  • What is CSS? Explain the types of CSS.
  • Explain function in JavaScript?
  • Explain Date and Time functions in JavaScript
  • Explain Object creation and modification in Javascript
  • Explain Following HTML Tag with example: (1)
    • (i) Title, Head 
    • (ii) OL, UL , DL
    • (iii) Table with TH,TR,TD
  • Write a java script to check whether a number entered in textbox is prime or not.
  • In Javascript, eval("2 + 0.56") returns ______. (1)
  • In HTML, <ol> tag is used to create list items with bullets. (True / False) (1)
  • Write the advantages of JavaScript. Explain any three methods of Date and String objects of JavaScript. (7)
  • Explain the various types of inputs provided by HTML. (7)
  • Write a Javascript that changes background color to red if user presses the mouse button. (4)
  • Write a JavaScript function to add two numbers when user presses submit button. (3)
  • JavaScript is created by______ . (Sun, Microsoft, Netscape) (1)
  • What will be assign in variable mca by following JavaScript var mca = parseInt(“0xff”); Ans:255  (1 mark)
  • JavaScript is compiled and executed at client. (True / False) (1)
  • _________ is only property of string object in JavaScript. (1)
  • Java is _______________and JavaScript is ___________________. (2)
  • True or False. JavaScript Ignores White Space. (1)
  • What is the code in HTML so that someone can mail by just clicking on text? (1)
  • Write a code for create a multiple list in HTML. (1)
  • Which two methods are used for takes keyboard input and screen output in Java Script? (1)
  • What is the correct JavaScript syntax to write “Hello World”? (1)
  • HTML elements with no content are called _______ elements (1)
  • Explain Array in JavaScript with Example (3)
  • Write a JavaScript to input two numbers and find out max. Put validation - both value is not null. (7)
  • The <select> tag allows multiple choice selection from list of choices that are offered. (True/False) (1)
  • The Date object contains information about a particular date and time. (True/False) (1)
  • Explain DOM hierarchy. List two important methods of Window and Document Object. (7)
  • What is special about Math object? Explain any two methods of String, Date and Array object.(7)
  • Which tag is used to write JavaScript in HTML? (1)
  • Explain functionality of Join() & Reverse() function of array in JavaScript. (2)
  • Explain basic structure of HTML document. (3)
  • Explain various dialog box provided by JavaScript. (3)
  • Explain Table tag of HTML with example. (7)
  • We can save external JavaScript file with ____ extension. (1)


postheadericon RequestDispatcher include Example




postheadericon JavaScript Exercises



1.  Write a JavaScript that shows how a variable’s type can be changed on-the-fly.
2.  Write a JavaScript that demonstrates the use of +=,-=,*=,/= operators.
3.  Create a Form in HTML with two fields, minimum and maximum, write JavaScript to validate that only numeric value is entered in both, and the value entered in minimum is less than the value entered in maximum.
4.  Write a JavaScript that finds out multiples of 10 in 0 to 10000. On the click of button start the timer and stop the counter after 10 seconds. Display on the screen how many multiples of 10 are found out within stipulated time.
5.  Write a JavaScript to generate two random numbers and find out maximum and minimum out of it.

Follow by Email

Total Pageviews

© BipinRupadiya.com. Powered by Blogger.