20160113 First Andriod Development log

Source: Internet
Author: User

The first Andriod program was developed today to test recording and playback functions. The source code is copied online.

Code:

Unit Unit2;

Interface

Uses
System.sysutils, System.types, System.uitypes, system.classes, System.variants,
FMX. Types, FMX. Controls, FMX. Forms, FMX. Graphics, FMX. Dialogs, Fmx.stdctrls,
FMX. Media, System.ioutils;

Type
TForm2 = Class (Tform)
Btnstartrecord:tbutton;
Btnstoprecord:tbutton;
Imgon:tlabel;
Btnplay:tbutton;
Procedure Btnstartrecordclick (Sender:tobject);
Procedure Btnstoprecordclick (Sender:tobject);
Procedure Formcreate (Sender:tobject);
Procedure Btnplayclick (Sender:tobject);
Private
{Private declarations}
Public
{Public declarations}
End

Var
Form2:tform2;
Fmicrophone:taudiocapturedevice;

Implementation

{$R *.FMX}

Procedure Tform2.btnplayclick (sender:tobject);
var
  A:tmediaplayer;
Begin
  A: = Tmediaplayer.create (self);
  Try
    a.filename: = Tpath.gethomepath + '/recordtest.3gp ';
    a.play
  finally
    Freeandnil (a);
  END;
End;

Procedure Tform2.btnstartrecordclick (sender:tobject);
//Start recording
Begin
  Fmicrophone: = TCaptureDeviceManager.Current.DefaultAudioCaptureDevice;
  If Assigned (fmicrophone) then
  BEGIN
    fmicrophone.filename: = Tpath.gethomepath + '/recordtest.3gp ';
    try
      fmicrophone.startcapture;
      imgon.visible: = True;
    except
      on E:exception do
       BEGIN
        imgon.visible: = False;
        showmessage (' device is not recognized or not supported. ' + e.message);
      end
    end;
  End
  Else
    showmessage (' no microphones available. ‘);
End;

Procedure Tform2.btnstoprecordclick (Sender:tobject);
Stop Recording
Begin
If Assigned (Fmicrophone) Then
Try
If fmicrophone.state = Tcapturedevicestate.capturing Then
Begin
Fmicrophone.stopcapture;
Imgon.visible: = False;
End
Except
Imgon.visible: = False;
ShowMessage (' equipment is not recognized or not supported ');
End
End

Procedure Tform2.formcreate (Sender:tobject);
Begin
Imgon.visible: = False;
End

End.

Several questions:

1. Release: Project->deployment, click on deploy to do it. Can produce an apk file, through QQ transmission to the phone, you can install and run, good magic.

2. Runtime prompt: Setaudiosource failed, on-line check the next, found to be a permission problem,

In the Androidmanifest.xml file, add:

<uses-permission
Android:name= "Android.permission.RECORD_AUDIO" >
</uses-permission>

3.230 on the DELPHI7 has been running a problem, has not been resolved before, a compilation error, after the online check, delete hkey_current_user\software\embarcadero\bds\15.0 on it.

4. Home testing, the XE7 has been unable to display the connection of the phone, and later changed to a connection line on it, depressed.

20160113 First Andriod Development log

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.