Skip to content

Instantly share code, notes, and snippets.

View Pulimet's full-sized avatar
🏠
Working from home

Alexey Korolev Pulimet

🏠
Working from home
View GitHub Profile
@Pulimet
Pulimet / GetAdID
Created September 11, 2017 11:48
Get advertising id
public static String getAdvertisingId() {
try {
return AdvertisingIdClient.getAdvertisingIdInfo(Contextor.getInstance().getContext()).getId();
} catch (IOException e) {
e.printStackTrace();
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
} catch (GooglePlayServicesRepairableException e) {
e.printStackTrace();
}
@Pulimet
Pulimet / AdbCommands
Last active April 25, 2024 01:46
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
@Pulimet
Pulimet / CustomTabStrip.java
Created September 11, 2017 06:18
Custom tab strip for ViewPager (titles + current indicator)
/**
* PagerTitleStrip is a non-interactive indicator of the current, next,
* and previous pages of a {@link ViewPager}. It is intended to be used as a
* child view of a ViewPager widget in your XML layout.
* Add it as a child of a ViewPager in your layout file and set its
* android:layout_gravity to TOP or BOTTOM to pin it to the top or bottom
* of the ViewPager. The title from each page is supplied by the method
* {@link PagerAdapter#getPageTitle(int)} in the adapter supplied to
* the ViewPager.
*/
@Pulimet
Pulimet / gist:6cf1d0e1ab5f59e6711c
Last active July 4, 2016 04:57
UI / non UI thread
if (Looper.getMainLooper().equals(Looper.myLooper())) {
// UI thread
} else {
// Non UI thread
}
// Run on UI
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
try {
PackageInfo info = getPackageManager().getPackageInfo("com.xxx.yyy", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (PackageManager.NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
@Pulimet
Pulimet / Get Extras Info
Created December 4, 2014 11:03
To get information on an undocumented (3rd-party) intent:
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
Log.d(TAG, String.format("%s %s (%s)", key,
value.toString(), value.getClass().getName()));
}