Posts

Showing posts with the label Android

RUN JAVA PROJECT IN ANDROID STUDIO

You can compile and run java module as stand alone java project in Android Studio IDE. Follow the below steps  Open your Android project in Android Studio. If you do not have one, create one. Click  File > New Module . Select  Java Library  and click  Next . Fill in the package name, etc and click  Finish . You should now see a Java module inside your Android project. Add your code to the Java module you’ve just created. Click on the drop down to the left of the run button. Click  Edit Configurations… In the new window, click on the plus sign at the top left of the window and select  Application A new application configuration should appear, enter in the details such as your main class and classpath of your module.

How to open the camera in android and handle it's run time permissions

public class BarcodeCaptureFragment extends BaseStackFragment implements BarcodeGraphicTracker.BarcodeUpdateListener, View.OnClickListener, CustomDialogFragment.IDialogEventListener { public static final String TAG = BarcodeCaptureFragment. class .getName(); // intent request code to handle updating play services if needed. private static final int RC_HANDLE_GMS = 9001 ; // permission request codes need to be < 256 private static final int RC_HANDLE_CAMERA_PERM = 2 ; // constants used to pass extra data in the intent public static final String AutoFocus = "AutoFocus" ; public static final String UseFlash = "UseFlash" ; public static final String BarcodeObject = "Barcode" ; private CameraSource mCameraSource ; private CameraSourcePreview mPreview ; //private GraphicOverlay<BarcodeGraphic> mGraphicOverlay; private RelativeLayout rlGiveYourBarCodeNumber ; private CameraSourcePreview previe...

How to access the each view of item by position in Recycler View in android ?

How to access the each view of item by position in Recycler View in android ? There are some methods to access the view of each item view to change or update the view during the run time. To access the view of the item view , consider the Recycler view as below, RecyclerView mainRecyclerView = (RecyclerView)view.findViewById(R.id.main_recycler_view); RecyclerAdapter adapter = new RecyclerAdapter(mContext); mainRecyclerView.setAdapter(adapter); main.setLayoutManager(new LinearLayoutManager(mContext));  To access the itemView of each position the following functions can be used,  1. View itemView = mainRecyclerView.getChildAt(positionOfItem);  2. View itemView = mainRecyclerView.findViewHolderForAdapterPosition(Position).itemView;  3. View itemView = mainRecyclerView.findViewHolderForPosition(Position).itemView;  4. Long itemId = mainRecyclerView.getAdapter().getItemId(position);       View itemView = mainRecyclerView.findViewHolderFor...

How to inflate a layout dynamically?

View view = getLayoutInflater().inflate(R.layout. start_text_view , null );

The Set Interface : java collection interface that guarantees no duplicates as well as preservation of insertion order

The Java platform contains three general purpose  Set  implementations:  HashSet ,  TreeSet , and  LinkedHashSet .  HashSet , which stores its elements in a hash table, is the best-performing implementation; however it makes no guarantees concerning the order of iteration.  TreeSet , which stores its elements in a red-black tree, orders its elements based on their values; it is substantially slower than  HashSet . LinkedHashSet , which is implemented as a hash table with a linked list running through it, orders its elements based on the order in which they were inserted into the set (insertion-order).  LinkedHashSet spares its clients from the unspecified, generally chaotic ordering provided by  HashSet  at a cost that is only slightly higher. You could try to build it by combining  Set  and  List . Any collection implementing  Set  should not allow duplicate elements, and any collection implementing...

Using Monkey Tool

This first post is dedicated to a wonderfull tool => Monkey ! If you had never heard of this tool, your life is turning better now. Monkey is a simple tool which allow to generate pseudo-random gestures , on a device or on an emulator . Shortly, you can in a few seconds simulate a user using your application, but a pretty stupid one (just as all users ?) because all his actions will be generated randomly. These actions won’t make any sense, but the aim here is to detect bugs in your app, and this can be very useful. Note 1 : This is absolutely not a substitute to other tests you should do (like unit tests…). Do what I say, not what I do  Note 2 : For this tut, I suppose you have one emulator or a device connected in debug mode (with ADB drivers installed). I won’t detail this part. Here we go, launching cmd, and browsing to [android-sdk-path]**/platform-tools. The basic command to use monkey is the following: adb shell monkey <options> For exampl...