Skip to content

Instantly share code, notes, and snippets.

View koocbor's full-sized avatar

Rob Cook koocbor

  • Everactive
  • Charlottesville, VA
View GitHub Profile
adb shell
screenrecord --verbose /sdcard/demo.mp4
`ctrl-c`
exit
adb pull /sdcard/demo.mp4
@koocbor
koocbor / gist:368dcd73088f4b87731b
Created April 14, 2015 14:24
Save image to Media Android
public static Uri addImageToGallery(Context context, String filepath, String title, String description) {
ContentValues values = new ContentValues();
values.put(Media.TITLE, title);
values.put(Media.DESCRIPTION, description);
values.put(Images.Media.DATE_TAKEN, System.currentTimeMillis());
values.put(Images.Media.MIME_TYPE, "image/jpeg");
values.put(MediaStore.MediaColumns.DATA, filepath);
return context.getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
}
@koocbor
koocbor / CreateDialog.java
Last active June 20, 2022 15:50
Full Screen Dialog in Android
FullScreenDialog dialog = new FullScreenDialog();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
dialog.show(ft, FullScreenDialog.TAG);
@koocbor
koocbor / Android Common Apps Share Intent
Last active August 29, 2015 14:05
Share Intent for Twitter, Facebook, mms and email
public Intent getShareChooser(String chooserText, final String extraSubject, final String extraLink,
final String emailBody, final String twitterBody) {
Intent emailIntent = new Intent();
emailIntent.setAction(Intent.ACTION_SEND);
// Native email client doesn't currently support HTML, but it doesn't hurt to try in case they fix it
emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(emailBody));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, extraSubject);
emailIntent.setType("message/rfc822");
@koocbor
koocbor / Spinner with hint
Last active August 29, 2015 14:01
Spinner with hint
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_dropdown_item) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent);
if (position == getCount()) {
((TextView)v.findViewById(android.R.id.text1)).setText("");
((TextView)v.findViewById(android.R.id.text1)).setHint(getItem(getCount())); //"Hint to be displayed"
}
/**
* copy from the internets:
* http://stackoverflow.com/questions/16030667/displaying-card-flip-animation-on-old-android
*
*/
public class FlipAnimation extends Animation
{
private Camera camera;
private View fromView;
@koocbor
koocbor / hex opacity
Last active August 29, 2015 13:57
Hex opacity values
Lighter / Darker - http://hexcolortool.com/
Taken from here: http://stackoverflow.com/questions/15852122/hex-transparency-in-colors
100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
@koocbor
koocbor / keystore commands
Last active April 24, 2017 12:04
keystore stuff
Get dev keystore fingerprint
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
Get prod keystore fingerprint
keytool -list -keystore your_keystore_name
Change store password
keytool -storepasswd -keystore keystorename
Enter keystore password: <old password>
@koocbor
koocbor / Dialog
Created March 18, 2014 18:41
Custom Dialog to Choose Sharing Intent with Filtering
Intent emailIntent = new Intent();
emailIntent.setAction(Intent.ACTION_SEND);
// Native email client doesn't currently support HTML, but it doesn't hurt to try in case they fix it
emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(extraText));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, extraSubject);
emailIntent.setType("message/rfc822");
PackageManager pm = getPackageManager();
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("text/plain");