Posts

Check App Info

//By Jetfrican Electro World Intent intent = new Intent(); intent.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", MainActivity.this.getPackageName(), null); intent.setData(uri); MainActivity.this.startActivity(intent);

Random Password Generator

} private static String generateRandomPassword() { String upperCaseChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; String lowerCaseChars = "abcdefghijklmnopqrstuvwxyz"; String numberChars = "0123456789"; String specialChars = "!@#$%^&*()_-+= ?/{}~|"; int max_length = 10; String allowedChars = upperCaseChars +lowerCaseChars+numberChars+specialChars; Random rn = new Random(); StringBuilder sb = new StringBuilder(max_length); sb.append(allowedChars.charAt(rn.nextInt(allowedChars.length()-1))); for(int i=sb.length();i

Activate Or Deactivate Data Connection

private final static String COMMAND_L_ON = "svc data enable "; private final static String COMMAND_L_OFF = "svc data disable "; private final static String COMMAND_SU = "su"; public static void setConnection(boolean enable,Context context){ String command; if(enable) command = COMMAND_L_ON; else command = COMMAND_L_OFF; try{ java.lang.Process su = Runtime.getRuntime().exec(COMMAND_SU); java.io.DataOutputStream outputStream = new java.io.DataOutputStream(su.getOutputStream()); outputStream.writeBytes(command); outputStream.flush(); outputStream.writeBytes("exit "); outputStream.flush(); try { su.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } outputStream.close(); }catch(java.io.IOException e){ e.printStackTrace(); } }

Material Snackbar

View contextView = findViewById(R.id.linear1); com.google.android.material.snackbar.Snackbar.make(contextView, "Message Deleted", com.google.android.material.snackbar.Snackbar.LENGTH_LONG) .setAction("Undo", new OnClickListener() { @Override public void onClick(View v) { // Respond to the click, such as by undoing the modification that caused // this message to be displayed }) });

Linear Swipe

//Create Linear1 //Add Linear2 to Linear1 //OnCreate linear2.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View p1, MotionEvent p2) { switch(p2.getAction()) { case MotionEvent.ACTION_DOWN: f = p2.getY(); break; case MotionEvent.ACTION_UP: t = p2.getY(); if (((f - t)

Image Crop

private void performCrop(Uri picUri) { try { Intent cropIntent = new Intent("com.android.camera.action.CROP"); // indicate image type and Uri cropIntent.setDataAndType(picUri, "image/*"); // set crop properties here cropIntent.putExtra("crop", true); // indicate aspect of desired crop cropIntent.putExtra("aspectX", 1); cropIntent.putExtra("aspectY", 1); // indicate output X and Y cropIntent.putExtra("outputX", 128); cropIntent.putExtra("outputY", 128); // retrieve data on return cropIntent.putExtra("return-data", true); // start the activity - we handle returning in onActivityResult startActivityForResult(cropIntent, PIC_CROP); } // respond to users whose devices do not support the crop action catch (ActivityNotFoundException anfe) { // display an error message String errorMessage = "Whoops - your device doesn't support the crop action!"; Toast toast = Toast.makeText(this...

File Picker

//Add This on Build dependencies { compile 'com.github.angads25:filepicker:1.1.1' } //Add Import file import com.github.angads25.filepicker.model.DialogProperties; import com.github.angads25.filepicker.model.DialogConfigs; import com.github.angads25.filepicker.view.FilePickerDialog; import com.github.angads25.filepicker.controller.DialogSelectionListener; //Add on File Chooser DialogProperties properties = new DialogProperties(); properties.selection_mode = DialogConfigs.SINGLE_MODE; properties.selection_type = DialogConfigs.FILE_SELECT; properties.root = new java.io.File(DialogConfigs.DEFAULT_DIR); properties.error_dir = new java.io.File(DialogConfigs.DEFAULT_DIR); properties.offset = new java.io.File(DialogConfigs.DEFAULT_DIR); properties.extensions = null; final FilePickerDialog dialog = new FilePickerDialog(MainActivity.this,properties); dialog.setTitle("Select a File"); dialog.setDialogSelectionListener(new DialogSelectionListener() { @Override public void o...