<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.avi.trial.MainActivity">
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/btn1"
android:background="@mipmap/camera"/>
</RelativeLayout>
*******************************************************************************************
MainActivity.java
package com.example.avi.trial;
import android.content.DialogInterface;
import android.content.Intent;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
ImageView imgvw1;
Button btn1;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();
btn1.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v)
{
Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent,100);
}
});
}
private void init()
{
btn1= (Button) findViewById(R.id.btn1);
}
}
Comments
Post a Comment