***FOR THE SOLUTION SEE MY LAST RESPONSE TO THIS THREAD***
I'm in the process of trying to replicate an app I made using Kotlin, but moving it over to Java. I have pasted the code for the creation of both ZXing scanner views on both apps. The pro
In Kotlin the code works perfect and you get a nice crisp camera view (same quality as the camera) however on Java it is incredibly low resolution, and I can't figure out why.
Any advice would be much appreciated.
Both versions are using ZXing 1.9.8.
I have put the screenshots/code in spoilers as to not make this post huge.
I'm in the process of trying to replicate an app I made using Kotlin, but moving it over to Java. I have pasted the code for the creation of both ZXing scanner views on both apps. The pro
In Kotlin the code works perfect and you get a nice crisp camera view (same quality as the camera) however on Java it is incredibly low resolution, and I can't figure out why.
Any advice would be much appreciated.
Both versions are using ZXing 1.9.8.
I have put the screenshots/code in spoilers as to not make this post huge.
Java:
public class MainActivity extends AppCompatActivity implements ZXingScannerView.ResultHandler {
private static final int REQUEST_CAMERA =1;
private ZXingScannerView scannerView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
scannerView = new ZXingScannerView(this);
setContentView(scannerView);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
if(checkPermission()){
Toast.makeText(MainActivity.this, "Permission is granted", Toast.LENGTH_LONG).show();
}else{
requestPermission();
}
}
}
Code:
class MainActivity : AppCompatActivity(),ResultHandler{
private var REQUES_CAMERA = 1
private var scannerView : ZXingScannerView?=null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
scannerView= findViewById(R.id.scanner)
//Checking permissions
if(!checkPermission()){
requestPermissions()
}
setupScanner()
}
private fun setupScanner() {
scannerView?.startCamera()
scannerView?.visibility = View.VISIBLE
(scannerView?.layoutParams as LinearLayout.LayoutParams).weight = 1f;
try {
// val num = parseDouble(txtInput?.text?.toString().substring(2,2))
} catch (e: NumberFormatException) {
//numeric = false
}
}
private fun checkPermission() : Boolean{
return ContextCompat.checkSelfPermission(this@MainActivity, android.Manifest.permission.CAMERA) ==PackageManager.PERMISSION_GRANTED
}
Last edited: