Skip to content

Instantly share code, notes, and snippets.

@tseglevskiy
tseglevskiy / 1.java
Last active March 31, 2017 08:50
Doze mode
if (
connectivityManager.getActiveNetworkInfo() != null &&
connectivityManager.getActiveNetworkInfo().isConnected() &&
(!powerManager.isDeviceIdleMode() ||
powerManager.isIgnoringBatteryOptimizations()))
{
// do something
}
@tseglevskiy
tseglevskiy / 1.java
Last active November 10, 2015 13:20
App Permissions
private void requestPermissionAndExecute(
final String permission,
final int requestCode,
final Runnable granted,
final Runnable denied
)
{
grantedActions.put(requestCode, granted);
deniedActions.put(requestCode, denied);
@tseglevskiy
tseglevskiy / 1.java
Last active November 12, 2015 10:57
Text Selection Demo
// floating menu on long click
callback = new AcCallback();
textView1.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (actionMode != null) {
return false;
}
@tseglevskiy
tseglevskiy / 1.xml
Last active November 12, 2015 16:16
App Links
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:host="jollydroid.ru" android:scheme="http"/>
<application
android:allowBackup="true"
android:fullBackupContent="@xml/mybackupscheme"
.......
android:backupAgent=".MyBackupAgent"
>
.......
</application>
@tseglevskiy
tseglevskiy / ExecTerminal.java
Created October 29, 2016 23:11
How to use 'su' command in Android
/*******************************************************************************
* Origin: https://github.com/alt236/Wifi-Key-Recovery---Android/blob/master/src/aws/apps/wifiKeyRecovery/util/ExecTerminal.java
*
* Copyright 2011 Alexandros Schillings
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@tseglevskiy
tseglevskiy / hello.kt
Last active August 16, 2018 09:37
Hello, Gist!
class HelloWorld