Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center">
- <Button
- android:id="@+id/test"
- android:text="Take Picture"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"/>
- </LinearLayout>
- package com.mycompany.myapp;
- import android.app.*;
- import android.os.*;
- import android.content.*;
- import android.widget.Button;
- import android.view.*;
- import android.text.*;
- import android.content.Intent;
- import android.provider.*;
- public class MainActivity extends Activity
- {
- @Override
- protected void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- final Button but=(Button)findViewById(R.id.test);
- but.setOnClickListener(new View.OnClickListener(){
- public void onClick(View v){
- Intent tp=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- if(tp.resolveActivity(getPackageManager())!=null){
- startActivity(tp);
- }
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment