Skip to content

Instantly share code, notes, and snippets.

View douzifly's full-sized avatar
🙄
I may be slow to respond.

xy douzifly

🙄
I may be slow to respond.
View GitHub Profile
@douzifly
douzifly / gist:10837564
Created April 16, 2014 09:05
TextView 滚动
<TextView
android:id="@+id/textView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:singleLine="false"
/>
TextView textView = (TextView)findViewById(R.id.textView);
@douzifly
douzifly / gist:11086408
Created April 19, 2014 14:43
android get package name from jni
static jstring getpkg(JNIEnv* env, jobject thiz, jobject activity) {
jclass android_content_Context =env->GetObjectClass(activity);
jmethodID midGetPackageName = env->GetMethodID(android_content_Context,"getPackageName", "()Ljava/lang/String;");
jstring packageName= (jstring)env->CallObjectMethod(activity, midGetPackageName);
return packageName;
}
@douzifly
douzifly / gist:30a7df87c78ac58815f6
Created May 9, 2014 15:49
android launcher icon size
LDPI should be 36 x 36.
MDPI should be 48 x 48.
TVDPI should be 64 x 64.
HDPI should be 72 x 72.
XHDPI should be 96 x 96.
@douzifly
douzifly / gist:44ce824fafc49900ddac
Created June 4, 2014 03:13
override dispatchACtivityResult
void dispatchActivityResult(String who, int requestCode, int resultCode,
Intent data) {
if (who != null) {
Activity act = mLocalActivityManager.getActivity(who);
// if (true) Log.v(
// TAG, "Dispatching result: who=" + who + ", reqCode=" + requestCode
// + ", resCode=" + resultCode + ", data=" + data
// + ", rec=" + act);
if (act != null) {
// act.onActivityResult(requestCode, resultCode, data);
package com.qvod.player.utils;
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
import android.annotation.SuppressLint;
import android.content.Context;
@douzifly
douzifly / gist:833d9b9568f29f0a2953
Created June 13, 2014 03:40
postOnLayoutFinished
public static void postOnLayoutFinished(final View v, final Runnable r) {
if (v == null || r == null) {
throw new NullPointerException();
}
v.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
r.run();
@douzifly
douzifly / gist:176d8072e0c0a2665379
Created June 13, 2014 03:45
Android FullScreen
public static void setFullScreen(Window window, boolean fullScreen) {
if (fullScreen) {
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
}
public static boolean isFullScreen(Window window) {
return (window.getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0;
@douzifly
douzifly / gist:148975a2feed13904b2f
Created June 30, 2014 06:13
dialog width match parent
void show() {
final Dialog dialog = new Dialog(this);
final Window window = dialog.getWindow();
window.requestFeature(Window.FEATURE_NO_TITLE);
window.setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
// set content view must before set other attributes
dialog.setContentView(R.layout.dialog_content);
final WindowManager.LayoutParams lp = window.getAttributes();
@douzifly
douzifly / gist:87f122967b966e7e1952
Created July 22, 2014 09:27
android handle set as wallpaper
<intent-filter>
<action android:name="android.intent.action.ATTACH_DATA" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content" />
<data android:scheme="file" />
<data android:mimeType="image/*" />
<category android:name="android.intent.category.ALTERNATIVE" />
<category android:name="android.intent.category.SELECTED_ALTERNATIVE" />
</intent-filter>
@douzifly
douzifly / gist:4bfa54349dbbc5192672
Created December 1, 2014 14:41
fix android emulator sdcard readonly
mount -o rw,remount rootfs /
chmod 777 /mnt/sdcard