Android监听用户打开系统相机进行录像行为

首先,新建一个广播:

public class CameraReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        T.log("监听到了摄像完毕的广播");
        Cursor cursor = context.getContentResolver().query(intent.getData(),
                null, null, null, null);
        cursor.moveToFirst();
        String path = cursor.getString(cursor.getColumnIndex("_data"));
        String name=context.getString(cursor.getColumnIndex("_display_name"));
        T.log("path:"+path+" name:"+name);
    }
}

然后在manifest注册:

  <receiver
            android:name=".receiver.CameraReceiver"
            android:enabled="true" >
            <intent-filter android:priority="2147483647" >
                <action android:name="com.android.camera.NEW_VIDEO" />
                <action android:name="android.hardware.action.NEW_VIDEO" />

                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="*/*" />
            intent-filter>

        receiver>

你可能感兴趣的:(安卓开发)