Skip to content

Instantly share code, notes, and snippets.

View ibrahim4851's full-sized avatar
🎯
Focusing

ibrahim4851

🎯
Focusing
View GitHub Profile
@ibrahim4851
ibrahim4851 / build.gradle
Last active May 4, 2021 12:43
GradleMlKit
implementation 'com.google.android.gms:play-services-mlkit-text-recognition:16.1.3'
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ibrahim.mlkit">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-feature
android:name="android.hardware.camera"
@ibrahim4851
ibrahim4851 / file-paths.xml
Created May 4, 2021 20:31
File-PathsMlkit
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="my_images" path="Android/data/com.ibrahim.mlkit/files/Pictures" />
</paths>
@ibrahim4851
ibrahim4851 / activity_main.xml
Last active May 4, 2021 20:35
ActivityMainMlkit
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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=".MainActivity">
<ImageView
android:id="@+id/text_image"
@ibrahim4851
ibrahim4851 / camera.kt
Created May 4, 2021 20:57
CameraFuncMlkit
private fun camera(){
val takePictureIntent = Intent(MediaStore.ACTION_IMAGE_CAPTURE)
if (takePictureIntent.resolveActivity(
packageManager
) != null
) {
var photoFile: File? = null
try {
photoFile = createImageFile()
} catch (ex: IOException) {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode != RESULT_CANCELED) {
if (requestCode == PICK_IMAGE) {
data?.data?.let {
bitmap = null
bitmap = getBitmapFromUri(it)
Glide.with(this)
.load(bitmap)
@ibrahim4851
ibrahim4851 / pickImage.kt
Created May 4, 2021 21:01
PickImageMlkit
private fun pickImage() {
val intent = Intent()
intent.type = "image/*"
intent.action = Intent.ACTION_GET_CONTENT
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE)
}
@ibrahim4851
ibrahim4851 / detectImage.kt
Created May 4, 2021 22:48
DetectImageMlkit
fun detectImage() {
val recognizer = TextRecognition.getClient()
bitmap?.let {
val image = InputImage.fromBitmap(it, 0)
recognizer.process(image)
.addOnSuccessListener { visionText ->
Toast.makeText(this, visionText.text, Toast.LENGTH_SHORT).show()
}
.addOnFailureListener { e ->
Toast.makeText(this, "Error: " + e.message, Toast.LENGTH_SHORT).show()
@ibrahim4851
ibrahim4851 / AndroidManifest.xml
Created May 22, 2021 11:26
VolleyRequestsManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ibrahim.volleyrequests">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:usesCleartextTraffic="true"
...
</application>
@ibrahim4851
ibrahim4851 / activity_main.xml
Created May 22, 2021 11:43
MainActivityXmlVolley
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:orientation="vertical"
android:gravity="center"
tools:context=".MainActivity">