啓動系統照相機Camera的方法

1、直接調用系統的照相機功能

       

<Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="StartCamera" 
        android:onClick="startCamera"/>


具體實現代碼:

public void  startCamera(View view){
       Intent intent=new Intent();
       intent.startAction(MediaStore.ACTION_IMAGE_CATPURE);
       startActivity(intent);
}

2、讓自己的app也具有照相機的功能

需要在 AndroidManifest.xml文件中使用過濾器(必須設置category是default,否則這個照相機的功能是無用的)

        

<intent-filter>
     <action android:name="android.media.action.IMAGE_CAPTURE"/>
     <category  android:name="android.intent.category.DEFAULT"/>
</intent-filter>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章