Skip to content

Instantly share code, notes, and snippets.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity"
@f2prateek
f2prateek / MainActivity.java
Created January 20, 2013 19:21
Custom inner class in R.java?
package com.f2prateek.test;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity {
TextView mTextView;
@f2prateek
f2prateek / gist:3361083
Created August 15, 2012 15:39
AOKP ROMControl
08-15 09:33:43.488: I/ActivityManager(327): START {act=android.intent.action.MAIN cmp=com.aokp.romcontrol/.ROMControlActivity u=0} from pid 2404
08-15 09:33:43.496: E/AndroidRuntime(2404): FATAL EXCEPTION: main
08-15 09:33:43.496: E/AndroidRuntime(2404): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.aokp.romcontrol/com.aokp.romcontrol.ROMControlActivity}; have you declared this activity in your AndroidManifest.xml?
08-15 09:33:43.496: E/AndroidRuntime(2404): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1541)
08-15 09:33:43.496: E/AndroidRuntime(2404): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
08-15 09:33:43.496: E/AndroidRuntime(2404): at android.app.Activity.startActivityForResult(Activity.java:3351)
08-15 09:33:43.496: E/AndroidRuntime(2404): at android.app.Activity.startActivityForResult(Activity.java:3312)
08-15 09:33:43.496: E/AndroidRuntime(2404): at android.app.Activity.startActivity(Activity
@f2prateek
f2prateek / ShareToClipboard.java
Created August 8, 2012 05:26
Clipboard Share
package com.aokp.romcontrol;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import com.aokp.romcontrol.R;
package com.f2prateek.rx.preferences;
import android.content.SharedPreferences;
import android.support.annotation.Nullable;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
@f2prateek
f2prateek / check.go
Created September 27, 2015 08:16
Script that checks which component dependencies need to be updated.
package main
import (
"encoding/json"
"fmt"
"log"
"os"
"strings"
"sync"
@f2prateek
f2prateek / dex.java
Created January 20, 2015 09:19
Print all classes in a DexFile
try {
File dexFileOutputDir = context.getDir("dexFileOutput" + fileKey, Context.MODE_PRIVATE);
File dexFileOutputFile = new File(dexFileOutputDir, "dex");
DexFile dx =
DexFile.loadDex(jarFile.getAbsolutePath(), dexFileOutputFile.getAbsolutePath(), 0);
// Print all classes in the DexFile
for (Enumeration<String> classNames = dx.entries(); classNames.hasMoreElements(); ) {
String className = classNames.nextElement();
System.out.println("class: " + className);
}
@f2prateek
f2prateek / zip.java
Created January 20, 2015 09:18
Read classes in a Zipfile
try {
ZipFile zipFile = new ZipFile(jarFile);
for (Enumeration<? extends ZipEntry> entries = zipFile.entries();
entries.hasMoreElements(); ) {
String name = entries.nextElement().getName();
System.out.println("entry: " + name);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
@f2prateek
f2prateek / AndroidCI.md
Last active August 29, 2015 14:13 — forked from JvmName/Android CI

#Android and CI and Gradle (A How-To)

There are tech stacks in this world that make it dead simple to integrate a CI build system.
The Android platform is not one of them.

Although Gradle is getting better, it's still a bit non-deterministic, and some of the fixes you'll need will start to feel more like black magic than any sort of programming.

But fear not! It can be done!

Before we embark on our journey, you'll need a few things to run locally:

@f2prateek
f2prateek / Readme.md
Last active August 29, 2015 14:06
A Queue implementation for Tape.

A java.util.Queue implementation for Tape (does not support iteration).

Swapping implementations is easy!

@Module
class ProductionModule {
  @Provides @Named("payloads") Queue<Payload> providePayloadQueue(File queueFile, Converter<Payload> payloadConverter) {
    return new Tape<Payload>(queueFile, payloadConverter);
 }