barcode generator visual basic 6 source code AndroidManifest.xml in Java

Encode QR Code in Java AndroidManifest.xml

Listing 10.9 AndroidManifest.xml
Generate QR Code In Java
Using Barcode printer for Android Control to generate, create QR image in Android applications.
www.OnBarcode.com
Generating PDF 417 In Java
Using Barcode encoder for Android Control to generate, create PDF417 image in Android applications.
www.OnBarcode.com
< xml version="1.0" encoding="utf-8" > <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.msi.manning.chapter10.VideoCam" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".VideoCam" 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> <uses-permission android:name="android.permission.CAMERA"> </uses-permission> <uses-permission android:name= "android.permission.RECORD_AUDIO"></uses-permission> <uses-permission android:name= "android.permission.RECORD_VIDEO"></uses-permission> <uses-permission android:name= "android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-feature android:name="android.hardware.camera" /> </manifest>
Draw Code 128B In Java
Using Barcode drawer for Android Control to generate, create Code 128B image in Android applications.
www.OnBarcode.com
Print Data Matrix 2d Barcode In Java
Using Barcode drawer for Android Control to generate, create Data Matrix ECC200 image in Android applications.
www.OnBarcode.com
Now that you ve defined the manifest, you need to create a simple layout that has a preview area and some buttons to start, stop, pause, and play your video recording. The layout is shown in the following listing:
GS1 - 13 Drawer In Java
Using Barcode generator for Android Control to generate, create EAN / UCC - 13 image in Android applications.
www.OnBarcode.com
Barcode Printer In Java
Using Barcode printer for Android Control to generate, create Barcode image in Android applications.
www.OnBarcode.com
Listing 10.10 maim.xml
Code39 Generation In Java
Using Barcode generator for Android Control to generate, create Code39 image in Android applications.
www.OnBarcode.com
Print USPS Confirm Service Barcode In Java
Using Barcode creation for Android Control to generate, create USPS PLANET Barcode image in Android applications.
www.OnBarcode.com
< xml version="1.0" encoding="utf-8" > <!-- This file is /res/layout/main.xml --> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"
Recognize QR Code In VB.NET
Using Barcode reader for .NET framework Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
Drawing QR Code In Java
Using Barcode printer for Java Control to generate, create QR Code JIS X 0510 image in Java applications.
www.OnBarcode.com
Recording video
Decode Code-39 In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Universal Product Code Version A Printer In None
Using Barcode generation for Font Control to generate, create UPC Code image in Font applications.
www.OnBarcode.com
android:layout_width="fill_parent" android:layout_height="fill_parent"> <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/relativeVideoLayoutView" android:layout_centerInParent="true"> <VideoView android:id="@+id/videoView" android:layout_width="176px" android:layout_height="144px" android:layout_centerInParent="true"/> </RelativeLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_centerHorizontal="true" android:layout_below="@+id/relativeVideoLayoutView"> <ImageButton android:id="@+id/playRecordingBtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/play" /> <ImageButton android:id="@+id/bgnBtn" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/record" android:enabled="false" /> </LinearLayout> </RelativeLayout>
Painting Code 39 Full ASCII In Objective-C
Using Barcode printer for iPad Control to generate, create Code 39 Full ASCII image in iPad applications.
www.OnBarcode.com
Read PDF417 In C#
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
You ll need to download this code from http://code.google.com/p/ unlocking-android/ to get the open source icons that we use for the buttons, or you can use your own.
Painting Data Matrix 2d Barcode In None
Using Barcode creation for Office Word Control to generate, create Data Matrix ECC200 image in Office Word applications.
www.OnBarcode.com
Making Linear Barcode In Visual Studio .NET
Using Barcode encoder for ASP.NET Control to generate, create 1D image in ASP.NET applications.
www.OnBarcode.com
NOTE
Scan PDF 417 In Visual Basic .NET
Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
Barcode Generator In None
Using Barcode generator for Software Control to generate, create Barcode image in Software applications.
www.OnBarcode.com
Video recording follows a set of steps that are similar to those for audio recording:
UPC-A Creator In Objective-C
Using Barcode generation for iPhone Control to generate, create GTIN - 12 image in iPhone applications.
www.OnBarcode.com
UCC - 12 Recognizer In C#
Using Barcode scanner for .NET framework Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
1 2 3
4 5 6 7 8 9
Create an instance of android.media.MediaRecorder. Set up a VideoView. To set a preview display on a view surface, use MediaRecorder. setPreviewDisplay(). Set the source for audio, using MediaRecorder.setAudioSource(). Set the source for video, using MediaRecorder.setVideoSource(). Set your encoding for audio, using MediaRecorder.setAudioEncoder(). Set your encoding for video, using MediaRecorder.setVideoEncoder(). Set output file format using MediaRecorder.setOutputFormat(). Set the video size using setVideoSize(). (At the time this book was written, there was a bug in setVideoSize that limited it to 320 by 240.)
10 11 12
Multimedia
Set the video frame rate, using setVideoFrameRate. Use prepare() and start() to prepare and start your recordings. Use stop() and release() to gracefully stop and clean up your recording process.
As you can see, using video is very similar to using audio. So let s go ahead and finish our example by using the code in the following listing.
Listing 10.11 VideoCam.java
VideoCam.java public class VideoCam extends Activity implements SurfaceHolder.Callback { private MediaRecorder recorder = null; private static final String OUTPUT_FILE = "/sdcard/uatestvideo.mp4"; private static final String TAG = "RecordVideo"; private VideoView videoView = null; private ImageButton startBtn = null; private ImageButton playRecordingBtn = null; private Boolean playing = false; private Boolean recording = false; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); startBtn = (ImageButton) findViewById(R.id.bgnBtn); playRecordingBtn = (ImageButton) findViewById(R.id.playRecordingBtn); videoView = (VideoView)this.findViewById(R.id.videoView); final SurfaceHolder holder = videoView.getHolder(); holder.addCallback(this); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); startBtn.setOnClickListener(new OnClickListener() { public void onClick(View view) { if(!VideoCam.this.recording & !VideoCam.this.playing) { try { beginRecording(holder); playing=false; recording=true; startBtn.setBackgroundResource(R.drawable.stop); } catch (Exception e) { Log.e(TAG, e.toString()); e.printStackTrace(); } } else if(VideoCam.this.recording)
Recording video
{ try { stopRecording(); playing = false; recording= false; startBtn.setBackgroundResource(R.drawable.play); }catch (Exception e) { Log.e(TAG, e.toString()); e.printStackTrace(); } } } }); playRecordingBtn.setOnClickListener(new OnClickListener() { public void onClick(View view) { if(!VideoCam.this.playing & !VideoCam.this.recording) { try { playRecording(); VideoCam.this.playing=true; VideoCam.this.recording=false; playRecordingBtn.setBackgroundResource (R.drawable.stop); } catch (Exception e) { Log.e(TAG, e.toString()); e.printStackTrace(); } } else if(VideoCam.this.playing) { try { stopPlayingRecording(); VideoCam.this.playing = false; VideoCam.this.recording= false; playRecordingBtn.setBackgroundResource (R.drawable.play); }catch (Exception e) { Log.e(TAG, e.toString()); e.printStackTrace(); } } } }); } public void surfaceCreated(SurfaceHolder holder) { startBtn.setEnabled(true);
Multimedia
public void surfaceDestroyed(SurfaceHolder holder) { } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { Log.v(TAG, "Width x Height = " + width + "x" + height); } private void playRecording() { MediaController mc = new MediaController(this); videoView.setMediaController(mc); videoView.setVideoPath(OUTPUT_FILE); videoView.start(); } private void stopPlayingRecording() { videoView.stopPlayback(); } private void stopRecording() throws Exception { if (recorder != null) { recorder.stop(); } } protected void onDestroy() { super.onDestroy(); if (recorder != null) { recorder.release(); } } private void beginRecording(SurfaceHolder holder) throws Exception { if(recorder!=null) { recorder.stop(); recorder.release(); } File outFile = new File(OUTPUT_FILE); if(outFile.exists()) { outFile.delete(); } try { recorder = new MediaRecorder(); recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); recorder.setVideoSize(320, 240); recorder.setVideoFrameRate(15); recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setMaxDuration(20000); recorder.setPreviewDisplay(holder.getSurface()); recorder.setOutputFile(OUTPUT_FILE);
Summary
recorder.prepare(); recorder.start(); } catch(Exception e) { Log.e(TAG, e.toString()); e.printStackTrace(); } } }
Because much of this code is similar to other code in this chapter, we won t describe everything that s happening. If you look quickly at the code in this listing, you ll note that it s relatively simple. The first thing we do in the code, besides setting some fields, is set up our surface to support the camera preview, much like we did in the simple camera application earlier in this chapter. The next part of the code that s important is the beginRecording method. First, this method checks to make sure that everything is ready to record a video file by making sure that the camera is free, and that it can record the output file. Then, it closely follows the preceding processes to set up the camera for recording before calling prepare() and then start(). Unfortunately, as we noted with the camera project, there s no easy way to test your application in the emulator. For this example, we ve pushed the application to a cell phone to test the camera, and used the DDMS to note the file that was recorded and to play it back. You can see an example of the output, captured with the DDMS, from an HTC Hero in figure 10.7. Without a device to test on, you ll have difficulties debugging your video applications. If you decide to develop a video application, we strongly suggest that you not only obtain an Android device to test on, but that you test every physical device that you hope your application will run on. Although developing Android applications that record data from sensors can be difficult to work with on the emulator, they re relatively Figure 10.7 Photograph of straightforward to code, but you need to use a physical VideoCam application running Android device to test. on an HTC Hero 2.
10.6 Summary
In this chapter, we looked at how the Android SDK uses multimedia and how you can play, save, and record video and sound. We also looked at various features the Android MediaPlayer offers the developer, from a built-in video player to wide support for formats, encodings, and standards. We talked about how to interact with other hardware devices attached to the phone, such as a microphone and camera. You used the SDK to create an SD card
Copyright © OnBarcode.com . All rights reserved.