This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void debugLog(String msg){ | |
final StackTraceElement stackTrace = new Exception().getStackTrace()[1]; | |
String fileName = stackTrace.getFileName(); | |
if (fileName == null) fileName=""; // It is necessary if you want to use proguard obfuscation. | |
final String info = stackTrace.getMethodName() + " (" + fileName + ":" | |
+ stackTrace.getLineNumber() + ")"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.Manifest; | |
import android.app.Activity; | |
import android.content.DialogInterface; | |
import android.content.pm.PackageManager; | |
import android.support.annotation.NonNull; | |
import android.support.v4.app.ActivityCompat; | |
import android.support.v7.app.AlertDialog; | |
import android.support.v7.app.AppCompatActivity; | |
import java.util.ArrayList; | |
import java.util.List; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*This instance of the class show will be registered in the android "Aplpication" instance | |
like activity.getApplication().registerActivityLifecycleCallbacks(new ApplicationTimeSpentTracker()); | |
*/ | |
public class ApplicationTimeSpentTracker implements Application.ActivityLifecycleCallbacks { | |
private int activityReferences = 0; | |
private boolean isActivityChangingConfigurations = false; | |
private long startingTime; | |
private long stopTime; | |
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.ParseException; | |
import java.util.Date; | |
public class ComparableDate implements Comparable<ComparableDate> { | |
private Date dateTime; | |
public Date getDateTime() { | |
return dateTime; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boolean isRotated= false; | |
View rotateLayout; | |
if(isRotated) | |
{ | |
rotateLayout.setRotation(360); | |
rotateLayout.setTranslationX(0); | |
rotateLayout.setTranslationY(0); | |
ViewGroup.LayoutParams lp = rotateLayout.getLayoutParams(); |
OlderNewer