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

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

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