Android | Techbirds | Page 2

  Asynchronous ImageLoading in Listview: There are some libraries available for async Image Loading. Some Of them are: 1.Universal Image Loading 2.AndroidQuery(AQuery)   Here I will explain Async image Loading with “Universal Image Loader”.Following are the steps: Step1: Download universal-image-loader-1.9.2.jar  file add add this in libs folder of your project.   Step2: Create the instance

Read More →

1,699 total views, no views today

Steps to record video are

mCamera = mPreview.getCamera(); //get Camera Intance mRecorder = new MediaRecorder(); //step1 mCamera.unlock(); mRecorder.setCamera(mCamera); //step2 mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); //step 3 //mRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH)); mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT); //step4 mRecorder.setOutputFile(getOutputFile(MEDIA_TYPE_VIDEO).toString()); //step 5 mRecorder.setPreviewDisplay(mPreview.getMyHolder().getSurface()); try { //step 6 mRecorder.prepare(); Thread.sleep(1000); mRecorder.start(); Toast.makeText(CameraPreview.this, “Recording Started”, Toast.LENGTH_LONG); } catch (Exception e) { releaseRecorder(); Toast.makeText(CameraPreview.this, “Recording error couldn’t start”, Toast.LENGTH_LONG); }

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

mCamera = mPreview.getCamera(); //get Camera Intance

mRecorder = new MediaRecorder();

//step1

mCamera.unlock();

mRecorder.setCamera(mCamera);

                //step2

mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);

mRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

                //step 3

//mRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));

mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);

mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);

                //step4

mRecorder.setOutputFile(getOutputFile(MEDIA_TYPE_VIDEO).toString());

                //step 5

mRecorder.setPreviewDisplay(mPreview.getMyHolder().getSurface());

try {

        //step 6

    mRecorder.prepare();

    Thread.sleep(1000);

    mRecorder.start();

    Toast.makeText(CameraPreview.this, “Recording Started”, Toast.LENGTH_LONG);

} catch (Exception e) {

    releaseRecorder();

    Toast.makeText(CameraPreview.this, “Recording error couldn’t start”, Toast.LENGTH_LONG);

}

  683 total views, no views today

683 total views, no views today

There are two ways to get the instance of current visible item in view Pager. 1. First way is: Step1: get the position of viewpager using int item = mViewpager.getCurrentItem(); Step2: find the tag of fragment using item which you added at the time of fragment add or replace String tag = “”; if(item ==

Read More →

12,317 total views, no views today

Posted on: May 20, 2014 /

Categories: Android, Tutorials / Author Name: Swapna Singh

There are two methods for playing sounds in android Soundpool and Media Player. Soundpool : Soundpool is designed for short clips which can be kept in memory decompressed for quick access, this is best suited for sound effects in apps or games. Using this method with soundboards is a bad idea as you will be loading

Read More →

2,874 total views, no views today

Below is the code for recording a voice through mic and saving it in sdcard :   //Code for saving recording private void startRecording(){ mRecorder = new MediaRecorder(); File sampleDir = Environment.getExternalStorageDirectory(); try { audiofile = File.createTempFile(“sound”, “.3gp”, sampleDir); } catch (Exception e) { // TODO: handle exception Log.e(“Path Error”, “Error in making directory”); }

Read More →

916 total views, no views today