1
I’m trying to integrate a scanner into my app and, at first, I did identical to what’s on github:
https://github.com/KingsMentor/MobileVisionBarcodeScanner
However, when I call Activityscanner the error occurs:
02-17 20:25:31.058 26651-26735/br.codes.locadoraFilmes E/dalvikvm: Could not find class 'com.google.android.chimera.Activity', referenced from method mu. b 02-17 20:25:31.088 26651-26651/br.codes.locadoraFilmes E/Androidruntime: FATAL EXCEPTION: main Process: br.codes.locadoraFilmes, PID: 26651 java.lang.Runtimeexception: Unable to resume Activity {br.codes.locadoraFilmes/br.codes.locadoraFilmes.view.Activityscanner}: android.util.Supernotcalledexception: Activity {br.codes.locadoraFilmes/br.codes.locadoraFilmes.view.Activityscanner} Did not call through to super.onResume() at android.app.Activitythread.performResumeActivity(Activitythread.java:2790) at android.app.Activitythread.handleResumeActivity(Activitythread.java:2819) at android.app.Activitythread.handleLaunchActivity(Activitythread.java:2254) at android.app.Activitythread.access$800(Activitythread.java:141) at android.app.Activitythread$H.handleMessage(Activitythread.java:1212) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.Activitythread.main(Activitythread.java:5113) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.Internal.os.Zygoteinit$Methodandargscaller.run(Zygoteinit.java:793) at com.android.Internal.os.Zygoteinit.main(Zygoteinit.java:609) at Dalvik.system.Nativestart.main(Native Method) Caused by: android.util.Supernotcalledexception: Activity {br.codes.locadoraFilmes/br.codes.locadoraFilmes.view.Activityscanner} Did not call through to super.onResume() at android.app.Activity.performResume(Activity.java:5326) at android.app.Activitythread.performResumeActivity(Activitythread.java:2780) at android.app.Activitythread.handleResumeActivity(Activitythread.java:2819) at android.app.Activitythread.handleLaunchActivity(Activitythread.java:2254) at android.app.Activitythread.access$800(Activitythread.java:141) at android.app.Activitythread$H.handleMessage(Activitythread.java:1212) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.Activitythread.main(Activitythread.java:5113) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.Internal.os.Zygoteinit$Methodandargscaller.run(Zygoteinit.java:793) at com.android.Internal.os.Zygoteinit.main(Zygoteinit.java:609) at Dalvik.system.Nativestart.main(Native Method) 02-17 20:25:31.158 2763-24817/? E/Vision: Download Failed: Status{statusCode=Download not allowed: Not enough room to download. , Resolution=null}
activity_scanner.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".view.ActivityScanner">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/actions"
android:layout_weight="1"
android:gravity="center">
<fragment
android:id="@+id/barcode"
android:name="com.google.android.gms.samples.vision.barcodereader.BarcodeCapture"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
app:gvb_auto_focus="true"
app:gvb_code_format="all_format"
app:gvb_flash="false"
app:gvb_rect_colors="@array/rect_color" />
</RelativeLayout>
<LinearLayout
android:id="@+id/actions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="4dp">
<android.support.v7.widget.SwitchCompat
android:id="@+id/focus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="auto focus" />
<android.support.v7.widget.SwitchCompat
android:id="@+id/draw_rect"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="18dp"
android:layout_weight="1"
android:text="draw rect" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="4dp">
<android.support.v7.widget.SwitchCompat
android:id="@+id/support_multiple"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="support multiple" />
<android.support.v7.widget.SwitchCompat
android:id="@+id/touch_callback"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="18dp"
android:layout_weight="1"
android:text="touch callback" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<android.support.v7.widget.SwitchCompat
android:id="@+id/draw_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="18dp"
android:layout_weight="1"
android:text="draw text" />
<CheckBox
android:id="@+id/from_xml"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text="From xml" />
<Button
android:id="@+id/refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Refresh" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Activityscanner.java
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.samples.vision.barcodereader.BarcodeCapture;
import com.google.android.gms.samples.vision.barcodereader.BarcodeGraphic;
import com.google.android.gms.vision.barcode.Barcode;
import java.util.List;
import br.codes.locadoraFilmes.R;
import xyz.belvi.mobilevisionbarcodescanner.BarcodeRetriever;
public class ActivityScanner extends FragmentActivity implements BarcodeRetriever{
SurfaceView preview = null;
SurfaceHolder previewHolder = null;
Camera camera;
boolean inPreview = false;
boolean cameraConfigured = false;
Dialog dialog;
Permissao p = new Permissao();
String tipoActivity = "";
ImageView buscaManual,buscaPorNome;
private static final String TAG = "BarcodeMain";
CheckBox fromXMl;
SwitchCompat drawRect, autoFocus, supportMultiple, touchBack, drawText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scanner);
final BarcodeCapture barcodeCapture = (BarcodeCapture) getSupportFragmentManager().findFragmentById(R.id.barcode);
barcodeCapture.setRetrieval(this);
fromXMl = (CheckBox) findViewById(R.id.from_xml);
drawRect = (SwitchCompat) findViewById(R.id.draw_rect);
autoFocus = (SwitchCompat) findViewById(R.id.focus);
supportMultiple = (SwitchCompat) findViewById(R.id.support_multiple);
touchBack = (SwitchCompat) findViewById(R.id.touch_callback);
drawText = (SwitchCompat) findViewById(R.id.draw_text);
findViewById(R.id.refresh).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (fromXMl.isChecked()) {
} else {
barcodeCapture.setShowDrawRect(drawRect.isChecked());
barcodeCapture.setSupportMultipleScan(supportMultiple.isChecked());
barcodeCapture.setTouchAsCallback(touchBack.isChecked());
barcodeCapture.shouldAutoFocus(autoFocus.isChecked());
barcodeCapture.setShouldShowText(drawText.isChecked());
barcodeCapture.refresh();
}
}
});
@Override
public void onRetrieved(final Barcode barcode) {
Log.d(TAG, "Barcode read: " + barcode.displayValue);
runOnUiThread(new Runnable() {
@Override
public void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(ActivityScanner.this)
.setTitle("code retrieved")
.setMessage(barcode.displayValue);
builder.show();
}
});
}
@Override
public void onRetrievedMultiple(final Barcode closetToClick, final List<BarcodeGraphic> barcodeGraphics) {
runOnUiThread(new Runnable() {
@Override
public void run() {
String message = "Code selected : " + closetToClick.displayValue + "\n\nother " +
"codes in frame include : \n";
for (int index = 0; index < barcodeGraphics.size(); index++) {
Barcode barcode = barcodeGraphics.get(index).getBarcode();
message += (index + 1) + ". " + barcode.displayValue + "\n";
}
AlertDialog.Builder builder = new AlertDialog.Builder(ActivityScanner.this)
.setTitle("code retrieved")
.setMessage(message);
builder.show();
}
});
}
@Override
public void onBitmapScanned(SparseArray<Barcode> sparseArray) {
}
@Override
public void onRetrievedFailed(String s) {
}
Manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="br.codes.locadoraFilmes"
android:installLocation="preferExternal"
android:screenOrientation="portrait">
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardwar.ListaProe.camera" />
<uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
tools:node="replace"
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="SocialMarket"
android:screenOrientation="portrait"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<meta-data android:name="com.google.android.gms.vision.DEPENDENCIES" android:value="barcode"/>
...
</aplication>
</manifest>
I apologize for the amount of code. I imagine the error is in some of these parts but I have no idea which.