Created
July 31, 2018 15:13
-
-
Save emersoncloud/c93d439222486beb0896e42c400b50a0 to your computer and use it in GitHub Desktop.
CameraKit Hello World
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context="com.example.emerson.camerakittest.MainActivity"> | |
<com.camerakit.CameraKitView xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:id="@+id/camera" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
app:camera_facing="back" /> | |
<android.support.v7.widget.AppCompatButton | |
android:id="@+id/photoButton" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:backgroundTint="@color/colorPrimary" | |
android:text=" Capture\nImage" | |
app:layout_constraintBottom_toBottomOf="parent" | |
app:layout_constraintEnd_toEndOf="parent" | |
app:layout_constraintStart_toStartOf="parent" /> | |
</android.support.constraint.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.android.application' | |
android { | |
compileSdkVersion 26 | |
defaultConfig { | |
applicationId "com.example.emerson.camerakittest" | |
minSdkVersion 23 | |
targetSdkVersion 26 | |
versionCode 1 | |
versionName "1.0" | |
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | |
} | |
buildTypes { | |
release { | |
minifyEnabled false | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
} | |
} | |
} | |
repositories { | |
maven { url 'https://dl.bintray.com/camerakit/camerakit-android' } | |
} | |
configurations.all { | |
resolutionStrategy.cacheChangingModulesFor 0, 'seconds' | |
} | |
dependencies { | |
implementation fileTree(dir: 'libs', include: ['*.jar']) | |
implementation 'com.android.support:appcompat-v7:26.1.0' | |
implementation 'com.android.support.constraint:constraint-layout:1.0.2' | |
testImplementation 'junit:junit:4.12' | |
androidTestImplementation 'com.android.support.test:runner:1.0.1' | |
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' | |
implementation 'com.camerakit:camerakit:1.0.0-beta1' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.emerson.camerakittest; | |
import android.os.Bundle; | |
import android.support.v7.app.AppCompatActivity; | |
import com.camerakit.CameraKitView; | |
public class MainActivity extends AppCompatActivity { | |
private CameraKitView cameraKitView; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
cameraKitView = findViewById(R.id.camera); | |
photoButton = findViewById(R.id.photoButton); | |
photoButton.setOnClickListener(photoOnClickListener); | |
} | |
@Override | |
protected void onResume() { | |
super.onResume(); | |
cameraKitView.onResume(); | |
} | |
@Override | |
protected void onPause() { | |
cameraKitView.onPause(); | |
super.onPause(); | |
} | |
@Override | |
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,@NonNull int[] grantResults) { | |
super.onRequestPermissionsResult(requestCode, permissions, grantResults); | |
cameraKitView.onRequestPermissionsResult(requestCode, permissions, grantResults); | |
} | |
private View.OnClickListener photoOnClickListener = new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
cameraKitView.captureImage(new CameraKitView.ImageCallback() { | |
@Override | |
public void onImage(CameraKitView cameraKitView, final byte[] photo) { | |
// manipulate image here | |
} | |
}); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment