Android SoundRecorder Design 2

Source: Internet
Author: User

Ii. SoundRecorder class Introduction

First, we will introduce the RemainingTimeCalculator class. It is responsible for calculating the number of Recording files that can be stored in the remaining storage space of the storage media. The timeRemaining () function is used to calculate the remaining time and calculate the remaining time based on the smaller limit on the file size and space size.

MCurrentLowerLimit = result <result2

? DISK_SPACE_LIMIT: FILE_SIZE_LIMIT;

 

The SoundRecorder class is an Activity. This class is responsible for implementing all the parts displayed to the user, including the interface and response to various operations. Recording, recording storage, and playback functions are implemented by calling methods in the Recorder class. The SoundRecorder contains the mRecorder object of a Recorder class.

As a subclass of the Activity class, SoundRecorder reloads multiple functions of the parent class:

OnCreate () onDestroy () (from startup to full destruction)

OnStart () onStop () (from visible to invisible)

OnPause () (from operable to unoperable)

These functions include the operations required for Activity switching between different States. The status switching here is caused by the influence of the SoundRecorder program, such as sleep on the mobile phone, program suspension, and switching from SoundRecorder program to other programs.

 

In addition, SoundRecorder also loads several functions:

OnConfigurationChanged (); when switching between landscape and landscape screens, refresh the UI.

OnSaveInstanceState (Bundle outState); saves the Recorder state to the Bundle. Actually, the saveState () function mentioned above is called. When the SoundRecorder needs to be interrupted for some reason, the status is saved, and then the corresponding code in onCreate () reads the status value in the Bundle at the restart to return the status of the program before the interruption, actually, the restoreState () function mentioned above is called.

OnPrepareOptionsMenu (), onOptionsItemSelected (), the two functions are responsible for implementing the menu key function.

 

From LuoXianXiong, your partner

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.