This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| adb shell screenrecord /sdcard/video.mp4 | |
| adb pull /sdcard/video.mp4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // To instantiate a RippleDrawable: | |
| // new RippleDrawable(null, null), the default constructor isn't public. | |
| // Unfortunately, this has no colors set, so the app will crash, here's another way | |
| int[] attrs = new int[] { android.R.attr.selectableItemBackground}; | |
| TypedArray array = getContext().obtainStyledAttributes(attrs); | |
| Drawable drawableFromTheme = array.getDrawable(0); | |
| array.recycle(); | |
| setBackground(drawableFromTheme); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public boolean isTwitterSignedIn(){ | |
| AccountManager manager = AccountManager.get(this); | |
| Account[] account = manager.getAccountsByType("com.twitter.android.auth.login"); | |
| if (account.length > 0) { | |
| Log.d("MainActivity", "Authenticated on twitter!"); | |
| return true; | |
| } else { | |
| return false; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MainActivity.this.runOnUiThread(new Runnable() { | |
| @Override | |
| public void run() { | |
| // Code to run on UI | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.apache.commons.lang3.StringUtils | |
| ... | |
| StringUtils.isBlank(myString) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int id = getResources().getIdentifier("name_of_resource", "id", getPackageName()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class OAuthActivity extends Activity { | |
| public static String OAUTH_URL = "https://github.com/login/oauth/authorize"; | |
| public static String OAUTH_ACCESS_TOKEN_URL = "https://github.com/login/oauth/access_token"; | |
| public static String CLIENT_ID = "YOUR_CLIENT_ID"; | |
| public static String CLIENT_SECRET = "YOUR_CLIENT_SECRET"; | |
| public static String CALLBACK_URL = "http://localhost"; | |
| @Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> | |
| <item android:id="@android:id/background"> | |
| <shape> | |
| <corners android:radius="5dip" /> | |
| <gradient | |
| android:startColor="#ff9d9e9d" | |
| android:centerColor="#ff5a5d5a" | |
| android:centerY="0.75" | |
| android:endColor="#ff747674" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private static boolean checkConnectivity(Context context){ | |
| ConnectivityManager connec = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); | |
| return (connec.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED || connec.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED); | |
| } |