不要使用扫描QR Ccode Google Api访问

时间:2017-03-14 18:37:44

标签: java android camera

我有扫描QR码的问题。 一步 第一个活动显示ma UUID设备

        Console.WriteLine("Enter the MealCost");

        decimal mealCost = Decimal.Parse(Console.ReadLine());
        int tipPercent = Int32.Parse(Console.ReadLine());
        int taxPercent = Int32.Parse(Console.ReadLine());

        // calulation Part

        decimal tip = mealCost * ((decimal)tipPercent / 100m);
        decimal tax = mealCost * ((decimal)taxPercent / 100m); 

        decimal totalCost = mealCost + tip + tax;

        Console.WriteLine(Math.Round(totalCost));
        Console.ReadLine();

}

第二次活动扫描Qr代码

private final static String EXTRA_MESSAGE = "uuidValue";
private static final int REQUEST_READ_PHONE_STATE = 1;
private static int REQUEST_CODE = 1;
private static TextView uuidTextView;


private String uunitValue;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_get_number);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    Typeface custom_fonts = Typeface.createFromAsset(getAssets(), "fonts/OpenSans-Light.ttf");

    Typeface custom_fonts2 = Typeface.createFromAsset(getAssets(), "fonts/OpenSans-Bold.ttf");

    TextView toolbarText = (TextView) findViewById(R.id.title_GetNumber);
    toolbar.setNavigationIcon(R.drawable.ic_restart);
    toolbarText.setTypeface(custom_fonts);

    TextView stageOneText = (TextView) findViewById(R.id.stageOneText);
    stageOneText.setTypeface(custom_fonts);

    TextView stageTwoText = (TextView) findViewById(R.id.stageTwoText);
    stageTwoText.setTypeface(custom_fonts);

    TextView stageThreeText = (TextView) findViewById(R.id.stageThreeText);
    stageThreeText.setTypeface(custom_fonts);

    TextView generateCard = (TextView) findViewById(R.id.textViewGenerationCard);
    generateCard.setTypeface(custom_fonts);


     uuidTextView = (TextView) findViewById(R.id.uniqueNumberTextView);
    uuidTextView.setTypeface(custom_fonts2);

  //  (PackageManager.PERMISSION_GRANTED == ActivityCompat.checkSelfPermission(ScanQrCodeActivity.this, Manifest.permission.CAMERA))

    if ( PackageManager.PERMISSION_GRANTED==ActivityCompat.checkSelfPermission(GetNumberActivity.this,Manifest.permission.READ_PHONE_STATE)) {

        uuidTextView.setText(deviceUDID(GetNumberActivity.this));
        uunitValue = deviceUDID(GetNumberActivity.this);

    }


    TextView nextButton = (TextView) findViewById(R.id.nextButton);
    nextButton.setTypeface(custom_fonts);
    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Intent intent = new Intent(GetNumberActivity.this, ScanQrCodeActivity.class);
            intent.putExtra(EXTRA_MESSAGE, uunitValue);
            startActivityForResult(intent, REQUEST_CODE);
        }
    });

}


@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        finish();
    }
    return super.onOptionsItemSelected(item);
}




public String deviceUDID(Context ctx) {
    final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
    final String tmDevice, tmSerial, androidId;
    tmDevice = "" + tm.getDeviceId();
    tmSerial = "" + tm.getSimSerialNumber();
    androidId = "" + android.provider.Settings.Secure.getString(ctx.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);

    UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
    String deviceId = deviceUuid.toString();
    Log.d("Device Id", deviceId);

    String newUUID = deviceId.replace("-", "");
    String code = newUUID.substring(23, 31);
    return code;
}

//show Alter Dialog
public void showAlterDialog(String title, String message) {
    final AlertDialog.Builder alert = new AlertDialog.Builder(GetNumberActivity.this);
    alert.setTitle(title)
            .setMessage(message)
            .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    alert.create();
    alert.show();
}

现在,我在手机上检查了Nexus 5,而华硕则显示对话框无法访问相机。作为测试Apke on tsblecie Samsung Tab 4所有视图出现DIY相机都可以扫描QR码。我不知道它是否实施得很糟糕。

0 个答案:

没有答案