Skip to content

Instantly share code, notes, and snippets.

View sreelallalu's full-sized avatar

sreelal sreelallalu

  • Trivandrum
View GitHub Profile
@sreelallalu
sreelallalu / AndroidManifest.xml
Last active December 8, 2023 22:42
Android USB detection
<uses-feature android:name="android.hardware.usb.host" />
<uses-permission android:name="android.permission.USB_PERMISSION" />
<activity android:name=".activities.MainActivity"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>
@sreelallalu
sreelallalu / remove old commits
Created August 8, 2018 06:17
Git remove old commits
git checkout --orphan TEMP_BRANCH
# Add all the files:
git add -A
# Commit the changes:
git commit -am "Initial commit"
# Delete the old branch:
git branch -D master
public class SelectedFilePath {
public static String getPath(final Context context, Uri uri)
{
//check here to KITKAT or new version
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
// DocumentProvider
@sreelallalu
sreelallalu / Firebase_server
Last active February 14, 2018 10:39
server-side PHP program Firebase
link : https://fcm.googleapis.com/fcm/send
postman
Header:
Authorization:key=AAAAqOQ4GK4:APA91bH0Fqsc9xfl2qMU8uhqOBSBYX1hFo-2p4m_GZtAzDLcyXhFCOpQO4E8oITOmtxS30IQuEqi3dl31b1uJPJsvlSwpGsnKKbVHbxELK1quQLchXZ9LLo_FuojLuehCVJImg_Sx_Cw
Content-Type:application/json
@sreelallalu
sreelallalu / Collection sorting List
Created January 3, 2018 04:59
Collection sorting List
public static List<Employee> getEmployeeListSortedByName() {
final List<Employee> employeeList = getEmployeeList();
Collections.sort(employeeList, new Comparator<Employee>() {
@Override
public int compare(Employee a1, Employee a2) {
return a1.getName().compareTo(a2.getName());
}
@sreelallalu
sreelallalu / ObjectAnimation
Created December 29, 2017 06:56
ObjectAnimation
public void Animate(View view)
{
Display display = getWindowManager().getDefaultDisplay();
Point point=new Point();
display.getSize(point);
final int width = point.y; // screen height
final float halfW = width/2.0f;
//Y orX transactionY or tranX
ObjectAnimator lftToRgt = ObjectAnimator.ofFloat( view,"Y",200,0f )
.setDuration(3200); // to animate left to right
@sreelallalu
sreelallalu / cutomtabhandler
Created December 11, 2017 10:56
TabLayoutCustomise
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Non focused states -->
<item android:state_selected="false"
android:drawable="@drawable/defualttab" />
<!-- Focused states (such as when focused with a d-pad or mouse hover) -->
<item android:state_selected="true"
@sreelallalu
sreelallalu / AlertDialogBox_Bgservice
Created December 6, 2017 10:28
AlertDialogBox_Onservice
Need Activity for display AlertDialog, because we can't display Dialog from any Service
Solution.
Create Activity as Dialog Theme and start that Activity from Service.
Just need to register you Activity in menifest.xml like as below
android:theme="@android:style/Theme.Dialog"
@sreelallalu
sreelallalu / Memory leak using LeakCanary
Created December 1, 2017 04:48
Memory leak using LeakCanary
dependency
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.4'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
Application
public class LeakCanaryApplication extends Application {
@sreelallalu
sreelallalu / gradle debug speed
Created November 30, 2017 12:46
gradle Debug Speed
org.gradle.daemon=true
org.gradle.parallel=true