We provide complete mobile and web apps development solutions

Saturday, March 2, 2013

How to test Android Application



Android testing suits are based on JUnit. Use JUnit to test a class but don't call Android API.If your new to android, use general purpose test cases such as AndroidTestCase.

Eclipse IDE:
Android Test cases can be run on Eclipse IDE or any other IDE.

Activity Testing: Activity testing base class is InstrumentationTestCase, which provides instrumentation to  test case.

Service Testing: Android provides service framework for testing service objects. We have to test the life cycle of service, such as onCreate() or onStartCommand().

Content Provider Testing: 
Android uses content providers to fetch the data and to store the data.The base test case class for content providers is  ProviderTestCase2.


UI testing: UI testing is more important in case of mobile application. Its also important to test application user interface.

How to test UI:

1. Install application on the test device and analyse UI components.

2. Create Automated tests to simulate UI, Compile test cases into a JAR file by installing it in test device.

3. Run the test and correct the bugs.



Why Manual testing:

In Mobile devices, varies the hardware from device model to model or manufacturer to manufacturer. So it is important to test the application in the hardware device even though simulating in the emulator. We cannot check the camera, Bluetooth, gps functionality in the emulator. So, use android test device for testing the application.











Monday, February 25, 2013

SurfaceView

android.view.SurfaceView

 SurfaceView class provides dedicated drawing surface.Surface is Zordered. It punches a hole in the window to allow the surface to be displayed. SurfaceView takes care of placing the view at correct place.
getHolder() - Access to the surface is provided through SurfaceHolder interface which can be retrieved by calling getHolder().

Implement SurfaceCreated, SurfaceDestroyed , SurfaceChanged to discover when the surface is created, changed, destroyed.


Here is the example for SurfaceView class

public class Surface


public class SurfaceExample extends SurfaceView
{
public SurfaceExample(Context context, AttributeSet attrSet)
{
super(context, attrSet);
}
}

Download Source code 

 

package com.srinivas.hellomr;

import java.io.IOException;

import android.os.Bundle;
import android.app.Activity;
import android.graphics.PixelFormat;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.Window;
import android.hardware.Camera;
import android.view.WindowManager;

public class MainActivity extends Activity implements SurfaceHolder.Callback {
    SurfaceHolder mSurfaceHolder;
    SurfaceView mSurfaceView;
    public Camera mCamera;
    boolean mPreviewRunning;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFormat(PixelFormat.TRANSLUCENT);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_main);
        mSurfaceView = (SurfaceView) findViewById(R.id.surfaceview);
        mSurfaceHolder = mSurfaceView.getHolder();
        mSurfaceHolder.addCallback(this);
        mSurfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }

    @Override
    public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
        if (mPreviewRunning) {

            mCamera.stopPreview();
        }
        Camera.Parameters p = mCamera.getParameters();
        mCamera.setParameters(p);
        try {
            mCamera.setPreviewDisplay(arg0);
        } catch (IOException e) {
            e.printStackTrace();
        }
        mCamera.startPreview();
        mPreviewRunning = true;
    }

    @Override
    public void surfaceCreated(SurfaceHolder holder) {
        mCamera = Camera.open();
    }

    @Override
    public void surfaceDestroyed(SurfaceHolder holder) {
        mCamera.stopPreview();
        mPreviewRunning = false;
        mCamera.release();
    }

    Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
        public void onPictureTaken(byte[] imageData, Camera c) {

        }
    };
}

 

 activity_main.xml

 <?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" android:id="@+id/layout">

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

    <SurfaceView
        android:id="@+id/surfaceview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

</LinearLayout>

 



Sunday, February 24, 2013

Forum

Post your query here and get fastest solution

HttpClient post in Android

To post the data to the server, to get the data from the server which is stored in remote database, we can use HttpClient for webservice requests.
 call HttpClient ,
HttpClient  client = new DefaultHttpClient();
Here is the example for HttpClient for posting the data, getting response from the server.

public class MainActivity extends Activity {
    TextView tv;
    String text;
    Button b;
    DefaultHttpClient client; 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    tv     = (TextView)findViewById(R.id.textView1);
     text     = "";
    }
     public void callWebService(View webService)
    {
      try {
            postData();
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
           }
  public void postData() throws JSONException{ 
        // Create a new HttpClient and Post Header
        client = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://192.168.0.1:8080/webservice/latest");        
        JSONObject json= new JSONObject();
           try {
            // JSON data:
                json.put("datapost",subJSON);
         StringEntity entity = new StringEntity(mainJSON.toString(), HTTP.UTF_8);
            httppost.setHeader("Content-Type","application/json");
            httppost.setEntity(entity);
            // Execute HTTP Post Request
            System.out.print(json);
            Log.e("tag", text);
            HttpResponse response = client.execute(httppost,localContext);
                      // for JSON:
            if(response != null)
            {
                InputStream is = response.getEntity().getContent();

                BufferedReader reader = new BufferedReader(new InputStreamReader(is));
                StringBuilder sb = new StringBuilder();

                String line = null;
                try {
                    while ((line = reader.readLine()) != null) {
                        sb.append(line + "\n");
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                } finally {
                    try {
                        is.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
                text = sb.toString();
            }
            tv.setText(text);
 }catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
        } catch (IOException e) {
            // TODO Auto-generated catch block
        }
    }

Wednesday, February 20, 2013

Android Developers -Freshers and Experienced




Picon Infotech Pvt Ltd            0-2 yrs            Android developer                   Click here to apply

OKIT Pvt Ltd                               0-2 yrs               Android Developer                    Click here to apply

 Smart Utility Systems           0-1 yr                Android Developer                 Click here to apply

Pennywise software               0-2 yrs               Android Developer                  Click here to apply 

Multiplex Systems Private Limited               Iphone Developer                      Click here to apply

 

 









HP hiring Software developers (freshers)

Qualifications:


Bachelors or Masters degree in Cse, It



Experience:



0-2 yrs


Skills:


Good analytical and problem solving skills.

Good knowledge of design of software applications.

Good communication skills.


Primary Location: 


Bangalore

MAQ hiring software engineers

Job location: Mumbai, Hyderabad

Position: Software Engineer

Experience:  Freshers (0 to 1 yr)

Event date: 09 march 2013

Eligibility:

2012 batch Btech

Graduates with PH score

Job Description:

Web app development using C#, SharePoint, Microsoft SQL Server,

XML Webservices

Business Intelligent app testing


Click here to apply


Online Training

Your Name :
Your Email: (required)
Your Message: (required)

Powered by Blogger.

Recent Posts

Find Us On Facebook

Popular Posts