android
Shared preferences for creating one time activity
Setting values in Preference: // MY_PREFS_NAME – a static String variable like: //public static final String MY_PREFS_NAME = “MyPrefsFile”; SharedPreferences.Editor editor = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE).edit(); editor.putString(“name”, “Elena”); editor.putInt(“idName”, 12); editor.apply(); Retrieve data from preference: SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE); String name = prefs.getString(“name”, “No name defined”);//”No name defined” is the default value. int idName = prefs.getInt(“idName”, … Read more
get the last picture taken by user
// Find the last picture String[] projection = new String[]{ MediaStore.Images.ImageColumns._ID, MediaStore.Images.ImageColumns.DATA, MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME, MediaStore.Images.ImageColumns.DATE_TAKEN, MediaStore.Images.ImageColumns.MIME_TYPE }; final Cursor cursor = getContext().getContentResolver() .query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, null, null, MediaStore.Images.ImageColumns.DATE_TAKEN + ” DESC”); // Put it in the image view if (cursor.moveToFirst()) { final ImageView imageView = (ImageView) findViewById(R.id.pictureView); String imageLocation = cursor.getString(1); File imageFile = new File(imageLocation); if … Read more
Find out the running process ID by package name
Since Android 7.0 the easiest way to find out the process ID by package name is to use pidof command: usage: pidof [-s] [-o omitpid[,omitpid…]] [NAME]… Print the PIDs of all processes with the given names. -s single shot, only return one pid. -o omit PID(s) Just run it like this: adb shell pidof my.app.package … Read more
Load large images with Picasso and custom Transform object
I found a solution.. In my Transform object I needed to scale the image (keeping aspect ratio) to 1024 x 768 max. Transform object was never called unless I call .resize(width, height) to resample down the image. For keeping aspect ratio and using resize I call .centerInside(). This way image will be scaled resample to … Read more
Register to be default app for custom file type
You can add the following to the AndroidManifest.xml file inside the activity that has to open the file (pdf in our case) <intent-filter > <action android:name=”android.intent.action.VIEW” /> <category android:name=”android.intent.category.DEFAULT” /> <data android:mimeType=”application/pdf” /> </intent-filter> Make sure you specify the proper mime format. The user will be prompted to choose your app if she wants to … Read more
Image upload using okHttp
You need to Use new MultipartBody.Builder() Instead of new MultipartBuilder() Its working
SIGNAL 11 SIGSEGV crash Android
Call webview.clearCache(); and webView2.destroyDrawingCache(); That should solve the problem.
Android Studio: Resolving Duplicate Classes
I added this line to my gradle.properties file and my app worked android.enableJetifier=true
How to render Android’s YUV-NV21 camera image on the background in libgdx with OpenGLES 2.0 in real-time?
The short answer is to load the camera image channels (Y,UV) into textures and draw these textures onto a Mesh using a custom fragment shader that will do the color space conversion for us. Since this shader will be running on the GPU, it will be much faster than CPU and certainly much much faster … Read more