Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions QRCode/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.truiton.mobile.vision.qrcode"
xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.truiton.mobile.vision.qrcode">

<uses-feature
android:name="android.hardware.camera"
android:required="true"/>
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
android:required="true" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>


<meta-data
android:name="com.google.android.gms.vision.DEPENDENCIES"
android:value="barcode"/>
<activity android:name=".MainActivity">
android:value="barcode" />
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.util.SparseArray;
Expand Down Expand Up @@ -134,6 +136,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
break;
}
}

if (barcodes.size() == 0) {
scanResults.setText("Scan Failed: Found nothing to scan");
}
Expand All @@ -145,13 +148,26 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
.show();
Log.e(LOG_TAG, e.toString());
}
/*Deleting the photo stored after clicking the picture*/
File photo = new File(Environment.getExternalStorageDirectory(), "picture.jpg");
if (photo.exists()) {
photo.delete();
}

}
}

private void takePicture() {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File photo = new File(Environment.getExternalStorageDirectory(), "picture.jpg");
imageUri = Uri.fromFile(photo);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
imageUri = FileProvider.getUriForFile(getApplicationContext(),
getApplicationContext()
.getPackageName() + ".provider", photo);
} else {
imageUri = Uri.fromFile(photo);
}

intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, PHOTO_REQUEST);
}
Expand Down
4 changes: 4 additions & 0 deletions QRCode/app/src/main/res/xml/provider_paths.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</paths>