I am imported the zxing android library for use via gradle, however I want to modify the way things are drawn. From my understanding, that can only be changed by changing the draw function in one of the classes in the library. The problem is I cannot modify the classes in the library due to them being imported with gradle.
Is there any way I can edit that file or even supply another file to override that one? Thanks for your time.
Edit:
Here is a link to the zxing github and the class that I am trying to change the functions in. I want to be able to change what the onDraw function does.
https://github.com/zxing/zxing/blob/master/android/src/com/google/zxing/client/android/ViewfinderView.java
I wasn't able to find a way to override the file, but I did find a workaround. I ended up extending the zXingScannerView file and did an override for the function setAutoFocus(boolean state). I chose that one because it was always called after the overlay was set and allowed me to easily remove it straight away.
Inside that funtion I did:
int chidrenCount = getChildCount();
for(int i = 0; i < childrenCount; i++) {
if(getChildAt(i) instanceof ViewFinderView) {
getChildAt(i).setVisibility(View.INVISIBLE);
}
}
Thanks for the help #FlyingPumba
if you refer to the Zxing Android library for working with Barcodes, it's Open Source !
That means you can download the source code of this library, import it to your project and make the changes you need.
For reading more on importing libraries to Android projects, read this SO question.
Also, if you feel that other users of ZXing would benefit from this change, you can always contribute to the library on GitHub.
Related
I'm handling an Android Project my company started last year.
I got a GreenDaoGenerator project with the infamous custom ExampleDaoGenerator.java. I'm pretty sure this is all well configured in order to work well and generate my entities.
I started developing the Android Project (which is in another folder/package, of course) but now I need to change the way Entities are instantiated in it.
I have a good amount of classes with the
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. Enable "keep" sections if you want to edit.
on the top of them and I'd like to re-generate them since I commented out some rows in my custom ExampleDaoGenerator.
How can I do that? GreenDaoGenerator is not an Android Studio project, doesn't have any build.gradle file. It doesn't have any .class file either, just the java file and libraries to load for DaoGeneration. I didn't find anywhere in GreenDao documentation how to run the proper generation and harvest the created classes.
I tried of course javac the.full.path/src/whatever/ExampleDaoGenerator.java but it didn't work :-(
Do you happen to see what I'm doing wrong? I expected Android Studio Project to re-generate the database whenever the signatures are changed but it seems like it does not.
Thank you
You need to add a Java library module (File > New > New module..) to your Android project (assuming you're using Android Studio), and insert the generation code inside public static void main(String[] args) {} in this module's .java class. Then Run it and the code will be generated in you main app's module.
See how I did it in my blog post.
mmm.... manually? backup previous created classes (model), run the generator again and compare-update data?
I don't know if there are any new doc here, but allways is a good reading place. get project also available.
Good luck!
I am having trouble with nonfree methdos usage in android. SIFT and SURF methods are not included in opencv-android-2.4.8. They are needed to be complied seperately.
https://sites.google.com/site/wghsite/technical-notes/sift_surf_opencv_android
This is the main tutorial about nonfree module compilation. However, the jni part for java users are not included. I have searched how to use compiled .so libraries but I could not achieve.
I wonder that someone can share the jni part for nonfree modules or detailed explanation for it, because I work on that issue over a week and I could not do it.
Thanks.
I am the author of the tutorial. I will be adding another tutorial showing the JNI part. Hope that will help. Please go back and check the tutorial in the next couple of days. I will post it soon.
I solved the problem. When you follow the tutorial(the link given in the question) you get the necessary libraries(.so files). In order to use them in java you do not need to implement jni part. When you load the libraries in your java code (System.load(libraryName)), then you can use sift and surf methods like the other detectors or descriptors. You can directly use the code pattern supplied by the opencv-2.4.8.
Assuming that you've already gotten OpenCV 4 Android to work on your Android device;
1) I placed libnonfree.so, libopencv_java.so and libgnustl_shared.so (not sure if the last one is needed) in the correct folder for your platform, in my case jniLibs/armeabi-v7a. Already compiled version can be find in the demo folder here; https://github.com/bkornel/opencv_android_nonfree
2) Make sure you load both libraries.
static {
System.loadLibrary("opencv_java");
System.loadLibrary("nonfree");
}
This was all that was required in order for it to work for me.
#fetifati, Do you mean to say that if I copy libnonfree.so and libopencv_java.so in say lib/armeabi folder and do System.load("nonfree"); System.load("opencv_java"), I can use code like:
private static final FeatureDetector detector = FeatureDetector
.create(FeatureDetector.SIFT);
private static final DescriptorExtractor extractor = DescriptorExtractor
.create(DescriptorExtractor.SIFT);
directly ? ... It doesn't seem to work for me. I am getting some errors.
:) :) Okay so I am new to LaTeX and Android (So don't hate me please). I am currently working on a project that involves the MimeTeX library working in an android application. (MimeTeX is the LaTeX library ported for android.)
Seeing that MimeTeX is written in C you have to use the native development kit.
I have the following in my main activity:
public native subraster rasterize ( char expression, int size );
static
{
System.loadLibrary("mimetex");
}
Now Eclipse is telling me that 'subraster' cannot be resolved as a type. So can anyone maybe help me and tell me what do I have to add to my MainActivity (in Java) for the subraster type to be valid? I have already configured all the paths and included the ndk-build.cmd to the build path of the C/C++ compiler.
Thank you, and I am sorry, but I am new to this. :) Even links with relevant information would be helpful (If you can find any)
I have done this with iOS perfectly and now I need it for Android. I have one codebase that can create unlimited different apps with a simple config file change.
Each app is created based on a complex XML config file that I included in the resources. All I make is one simple change in my strings.xml file and it points to the config file needed, which in turn makes this my project a new standalone app. Easy.
<string name="xmlconfig">nike-shoes</string>
But now that I have done that, how do I make the change so each app is it's own APK?
How can I switch between apps (and uploadable apk's) easily with one codebase and one project. I have heard people say "use a library and then just create a project for each that includes it" but that gets overly complicated when you have 15+ apps and growing.
And I've also seen people say "why not just make one app where you can switch between them all within the app" but that also is irrelevant to my project and doesn't make sense to my users. I can't explain more than that unfortunately, but the short answer is that this won't work as well.
What I did on the iOS project I have is that I just change the Bundle ID, change the code signing identify to match, change the app name, and point to the new plist from within my main Info.plist file. BAM! Whole new app. A few simple steps that takes me less than a minute.
How can I do this with Eclipse/Java/Android? What is the easiest way?
A few steps is fine, as long as I am not mucking with every file to get it done.
I figured I would answer my own question here using Android Studio (2.2.3 at the time I'm typing this), do the following:
In your AndroidManifest file, click on your package name (click the whatever part of com.myapp.whatever) and then hit Shift+F6. Choose "Rename package" and then rename it (without the com.myapp part). Don't do it for comments, strings, and text unless needed. You'll need to approve the refactor with the button at the bottom of the Android Studio window.
Check your build.gradle file and make sure your applicationId under defaultConfig matches what you changed it to.
In your strings.xml file, change your app_name and other strings as needed to make your app its own.
Takes me about 1-2 minutes to have a whole new app. Hopefully someone else finds this useful.
All you need to do is change the package name in the manifest(and a little re-factoring in your code file due to base package name changed), and the next build will create a new App.
If you want to maintain all your apps I would also recommend to create a branch for each app that will contain this change set. this way you can fix something and push it to all versions.
Lets say you change com.foo to com.foo.bar, then rebuild, all your R imports should be now added .bar, just find replace import com.foo.R to com.foo.bar.R, thats about it.
Convert your initial project in a library project, then reference to it from all other projects. This way you have a big advantage: all modification made to the library project are yet available in the other projects. Refernce: http://developer.android.com/tools/projects/projects-eclipse.html#SettingUpLibraryProject
Currently in one project I use GoogleMaps with ClusterMarker based on PhotSpot http://code.google.com/p/android-playground-erdao/wiki/PhotSpot.
I tried to convert it to use OpenStreetMap with mapsforge library( http://code.google.com/p/mapsforge/) replacing referenced libraries from googlemaps to mapsforge.
I need to override and implement method from mapsforge library in my custom class based on ClusterMarker ( http://code.google.com/p/android-playground-erdao/source/browse/trunk/SampleClusterMap/src/com/erdao/android/mapviewutil/markerclusterer/ClusterMarker.java ) from photspot and here I have hit the wall.
#Override
protected void drawOverlayBitmap(Canvas canvas, Point drawPosition, Projection projection,
byte drawZoomLevel) {
}
Did any of you tried to create clustermarker overlays on openstreetmap in java or maybe know any open source library that could help?
Thanks for great resource. Coincidentally, I was working on ItemClustering implementation for mapsforge too.
After importing SampleClusterMap source and making little adjustments to code I got it working. Here's a link to current project source http://ge.tt/7Zq63CH , most of changes are self explanatory. Don't forget to add mapsforge 0.3.0 library to build path.