Android App Development-----------------accept cameras to take pictures of radio and video broadcasts

Source: Internet
Author: User

Yesterday, suddenly asked to take photos and videos to obtain the time, to get accurate time is generally the time to press the shutter button or press the Stop button to generate the file is more accurate.

Because, if you click on the open app to take the photo or video button to get the time, it is necessary and real photo or video time error. Because there is time to load the camera, the focus time, and, after the user enters the photo page, it is possible not to immediately press the shutter to take pictures. So before taking the time is there must be error, than and uncontrolled. In one is to take a photo or video, click Finish or use, return to your app after the time, so there is a greater error, the user may be finished or after the recording did not immediately return to the app page, this situation is not controlled. So we can only invoke the camera's page, one is to press the shutter button, or press the Stop button.

Since the call to the camera is called the Android system, so I thought of the broadcast, sure enough, found that there are two corresponding broadcasts.

Android.hardware.action.NEW_PICTURE and Android.hardware.action.NEW_VIDEO

Register two broadcasts in the Androidmanifest.xml file, and then we can do what we want by filtering and accepting the broadcast.

Here is the configuration in the Androidmanifest.xml

<receiver android:name= "Com.example.getnettime.MyBroadcastReceiver" >            <intent-filter android: priority= "+" >                <action android:name= "Android.hardware.action.NEW_PICTURE"/>                <data android: Mimetype= "image/*"/>            </intent-filter>            <intent-filter android:priority= "+" >                < Action android:name= "Android.hardware.action.NEW_VIDEO"/>                <data android:mimetype= "video/*"/>            </intent-filter> </receiver>

The data note in the Intent-filter must be added, otherwise it will not be received.

And then we'll write another broadcast and accept it.

public class Mybroadcastreceiver extends Broadcastreceiver {@Overridepublic void OnReceive (context context, Intent Intent) {log.i ("TAG", "intent======>>>>>>" +intent.getaction ());}}

After receiving the broadcast, we can do what we want to do.

After testing, it was found that the broadcast was made when the file was generated, just by pressing the stop button. At the moment, there is no way to press the shutter, if a friend find ways please tell share

Android App Development-----------------accept cameras to take pictures of radio and video broadcasts

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.