Skip to content

Instantly share code, notes, and snippets.

View Gkemon's full-sized avatar
😎
Being humanized

Gk Mohammad Emon Gkemon

😎
Being humanized
View GitHub Profile
@Gkemon
Gkemon / SMSUtils.txt
Created September 5, 2022 17:24
SMS Utils for default SMS app
package com.emon.haziraKhata.sms;
import android.app.Activity;
import android.app.role.RoleManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.provider.Telephony;
@Gkemon
Gkemon / AndroidManifest.txt
Last active September 5, 2022 17:25
SMS default app manifest structure
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="*****">
<!-- SMS related permissions-->
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
@Gkemon
Gkemon / AndroidGallaryPhotoSaver.java
Last active April 16, 2022 09:15 — forked from samkirton/gist:0242ba81d7ca00b475b9
Fixed a bug where images added to the MediaStore are not inserted at the front of the gallery
package com.memtrip;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.graphics.Bitmap;
@Gkemon
Gkemon / LinkedList.java
Created July 7, 2021 18:14
LinkedList.java
public class TestLinkedListImplementation {
public static void main(String args[]) {
LinkedList ll = new LinkedList();
ll.addValue(1);
ll.addValue(2);
ll.addValue(3);
ll.addValue(4);
ll.addValue(5);
ll.addValue(6);
@Gkemon
Gkemon / RotateViewByToggle.java
Created April 1, 2021 06:46
Rotate view by toggle
boolean isRotated= false;
View rotateLayout;
if(isRotated)
{
rotateLayout.setRotation(360);
rotateLayout.setTranslationX(0);
rotateLayout.setTranslationY(0);
ViewGroup.LayoutParams lp = rotateLayout.getLayoutParams();
import android.animation.AnimatorInflater;
import android.animation.StateListAnimator;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
package com.ishtiaq.techlogicians.offergenie.list;
import android.content.Context;
import android.content.Intent;
import android.os.StrictMode;
import androidx.recyclerview.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
File file = new File(sdcard,"Android/file.txt");
StringBuilder text = new StringBuilder();
try {
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while ((line = br.readLine()) != null) {
String msg="My name is emon";
String directory_path = Environment.getExternalStorageDirectory().getPath();
File file = new File(directory_path,"/Android"); //"/Android" is the folder name
if(!file.exists()){
file.mkdir();
}
if (!file.exists()) {
file.createNewFile();
@Gkemon
Gkemon / Unix To Human Readable Time
Last active December 19, 2019 08:33
This gist is for conversion of unix to human readable time like "Just now", " 2 days ago" , " 6 hours later" etc.
public class unixToHuman {
private static final int SECOND_MILLIS = 1000;
private static final int MINUTE_MILLIS = 60 * SECOND_MILLIS;
private static final int HOUR_MILLIS = 60 * MINUTE_MILLIS;
private static final int DAY_MILLIS = 24 * HOUR_MILLIS;
private static final int WEEK_MILLIS = 7 * DAY_MILLIS ;
public static String getTimeAgo(long time) {
if (time < 1000000000000L) {
// if timestamp given in seconds, convert to millis