Skip to content

Instantly share code, notes, and snippets.

View akexorcist's full-sized avatar
🔥

Akexorcist akexorcist

🔥
View GitHub Profile
@akexorcist
akexorcist / Thread.java
Created July 22, 2014 14:45
All Thread
new Thread(new Runnable() {
public void run() {
}
}).start();
runOnUiThread(new Runnable() {
puclic void run() {
@akexorcist
akexorcist / GetPath.java
Created July 23, 2014 23:45
Get real path of uri from media store
@SuppressLint("NewApi")
public static String getPath(final Context context, final Uri uri) {
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
// DocumentProvider
if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
// ExternalStorageProvider
if (isExternalStorageDocument(uri)) {
@akexorcist
akexorcist / GetAppName.java
Created September 15, 2014 22:04
ค้นหา App Name จาก Package Name
PackageManager pm = getPackageManager();
String app_name = (String)pm.getApplicationLabel(pm.getApplicationInfo(package_name, PackageManager.GET_META_DATA));
<receiver android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<!--
IMPORTANT: If you change the package name of this sample app,
change "com.parse.tutorials.pushnotifications" in the lines
below to match the new package name.
Board : minnow
Bootloader : MINNOW094C
Brand : motorola
Characteristic : nosdcard,watch
CPU ABI : armeabi-v7a
CPU ABI2 : armeabi
Device : minnow
Display : KGW42R
Fingerprint : motorola/metallica/minnow:4.4W.1/KGW42R/1448224:user/release-keys
Hardware : minnow
@akexorcist
akexorcist / UltimateOnClickOverride.java
Last active August 29, 2015 14:13
Override OnClick แบบโคตรเหง้าเหล่ากอใน View นั้นๆ
public static void anyMethod(View view, Activity activity) {
final Activity mActivity = activity;
//Set up touch listener for non-text box views to hide keyboard.
if(!(view instanceof EditText)) {
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Do something here
}
});
String[] strEditText = { name, last, age, sex };
String[] strMessage = { "ช่องชื่อว่าง", "ช่องนามสกุลว่าง", "ช่องอายุว่าง", "ช่องเพศว่าง" };
for(int i = 0 ; i < strEditText.length ; i++) {
if(strEditText[i].length() == 0) {
message = strMessage[i]";
callMessage(title,message);
}
}
LayoutInflater mInflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View row = mInflater.inflate(R.layout.simple_list_item_1, parent, false);
TextView someTextView = (TextView)view.findViewById(R.id.txt_xxx);
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:gravity="center_vertical"
android:background="#FFFFFF">
<ImageView
android:layout_width="50dp"
{"Hardware Info":{"Android Info":{"System Type":"32-bit","Android Version":"5.1","Version Code":"Lollipop","API Version":"22","Incremental":"1743759","Codename":"REL"},"Build Info":{"Board":"shamu","Bootloader":"0x7108","Brand":"google","Characteristic":"nosdcard","CPU ABI":"armeabi-v7a","CPU ABI 2":"armeabi","Device":"shamu","Display":"LMY47D","Fingerprint":"google/shamu/shamu:5.1/LMY47D/1743759:user/release-keys","Hardware":"shamu","Host":"wpiu12.hot.corp.google.com","ID":"LMY47D","Manufacturer":"motorola","Model":"Nexus 6","Product":"shamu","Radio":"MDM9625_104446.01.02.95R","Serial":"ZX1G5236PK","Supported ABIS":"armeabi-v7a armeabi","Supported 32-bit ABIS":"armeabi-v7a armeabi","Supported 64-bit ABIS":"","Tags":"release-keys","Time":"1424322888000","Type":"user","User":"android-build"},"Communication Info":{"Vibrate Motor":"Yes","Microphone":"Yes","Telephony":"Yes","Cellular":"Yes","GPS":"Yes","Bluetooth":"Yes","Bluetooth LE":"Yes","WiFi":"Yes","WiFi Direct":"Yes","Ethernet":"Yes","WiMax":"No","USB OTG":