Skip to content

Instantly share code, notes, and snippets.

View sreereddymenon's full-sized avatar

Sree Reddy Menon sreereddymenon

  • Chicago
View GitHub Profile
@sreereddymenon
sreereddymenon / android-adb-pull-apk.md
Created September 24, 2019 19:33 — forked from ctrl-freak/android-adb-pull-apk.md
Retrieve APK from Non-Rooted Android Device through ADB

https://stackoverflow.com/a/18003462/348146

None of these suggestions worked for me, because Android was appending a sequence number to the package name to produce the final APK file name (this may vary with the version of Android OS). The following sequence of commands is what worked for me on a non-rooted device:

  1. Determine the package name of the app, e.g. com.example.someapp. Skip this step if you already know the package name.

    adb shell pm list packages

    Look through the list of package names and try to find a match between the app in question and the package name. This is usually easy, but note that the package name can be completely unrelated to the app name. If you can't recognize the app from the list of package names, try finding the app in Google Play using a browser. The URL for an app in Google Play contains the package name.

@sreereddymenon
sreereddymenon / Rover.java
Created September 8, 2019 23:34 — forked from cloudbank/Rover.java
Mars rover given a list of String cmds in an nxn matrix, return the square you end on.
public class Rover {
public static int roverMove(int matrixSize, List<String> cmds) {
int result = 0;
for (int i = 0; i < cmds.size(); i++) {
result = process(cmds.get(i), matrixSize, result);
}
return result;
}
static int process(String cmd, int n, int current) {
@sreereddymenon
sreereddymenon / app-module-build.gradle
Created September 9, 2016 12:12 — forked from segunfamisa/app-module-build.gradle
Using gradle extra properties to manage Android dependency versioning
// app module build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion rootProject.compileSdkVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
applicationId "com.segunfamisa.gradleextraproperties"
minSdkVersion rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion
@sreereddymenon
sreereddymenon / gradle_task_grant_permission
Created June 11, 2016 18:39 — forked from fangzhzh/gradle_task_grant_permission
gradle task to grant permission to device
android.applicationVariants.all { variant ->
def applicationId = variant.applicationId
def adb = androidadbExe. as String
def variantName = variant.name.capitalize()
def grantPermissionTask = task.create("create${variantName}Permissions") << {
"${adb} devices".execute().text.eachLine {
if(it.endsWith("device")){
def device = it.split()[0]
println "Granting permissions on devices ${device}"
"${adb} -s ${devices} shell pm grant ${applicationId} android.permission.ACCESS_FINE_LOCATION".execute()
@sreereddymenon
sreereddymenon / CustomRecyclerViewAdapter.java
Last active May 4, 2016 18:58 — forked from frapontillo/CustomRecyclerViewAdapter.java
How to use SwitchCompat inside a RecyclerView item
// omissis
@Override
public void onBindViewHolder(final CustomViewHolder holder, final int position) {
holder.mSwitch.setOnCheckedChangeListener(
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, final boolean isChecked) {
// TODO: handle your switch toggling logic here
}
@sreereddymenon
sreereddymenon / 1_drawable_ic_hash_io16.xml
Created March 21, 2016 13:53 — forked from nickbutcher/1_drawable_ic_hash_io16.xml
Animated Stroke. The google I/O website this year (https://google.com/io) has some funky animated lettering. I especially liked the animated stroke around the letters and wondered how you might implement that on Android. Turns out that AnimatedVectorDrawable makes this very easy! Here's how it looks: https://twitter.com/crafty/status/71077957997…
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2016 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@sreereddymenon
sreereddymenon / UploadService.kt
Created February 26, 2016 11:31 — forked from danielgomezrico/UploadService.kt
Android / Retrofit - how to upload a file without multipart (as binary) for Kotlin
interface UploadService {
@Headers("Content-Type: image/jpeg")
@POST("/files")
fun uploadFile(@Body file: TypedFile): Observable<UploadedFile>
}
@sreereddymenon
sreereddymenon / build.gradle
Created February 26, 2016 11:31 — forked from danielgomezrico/build.gradle
Android / add app version and build number to assembled apk.
def appVersionName = "1.0.0"
def appVersionCode = 12
android {
//...
defaultConfig {
//..
// Add version and build number to apk name
setProperty("archivesBaseName", "app-${appVersionName}-${appVersionCode}")
}
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.Canvas;
@sreereddymenon
sreereddymenon / Readme.md
Created February 9, 2016 13:27 — forked from gabrielemariotti/Readme.md
A SimpleSectionedRecyclerViewAdapter: use this class to realize a simple sectioned `RecyclerView.Adapter`.

You can use this class to realize a simple sectioned RecyclerView.Adapter without changing your code.

The RecyclerView should use a LinearLayoutManager. You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)

This is a porting of the class SimpleSectionedListAdapter provided by Google

Screen

Example: