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