This file contains 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
@Override | |
protected void onVisibilityChanged(@NonNull View changedView, int visibility) { | |
super.onVisibilityChanged(changedView, visibility); | |
switch (visibility){ | |
case VISIBLE://onResume called | |
case INVISIBLE:// onPause() called | |
} | |
} | |
@Override |
This file contains 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
# ... 以下はpython sdkの場所が/usr/local/google_appengineのケース | |
/usr/local/google_appengine | |
import sys, types, os;has_mfs = sys.version_info > (3, 5);p = os.path.join('/usr/local/google_appengine', *('google',));importlib = has_mfs and __import__('importlib.util');has_mfs and __import__('importlib.machinery');m = has_mfs and sys.modules.setdefault('google', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('google', [os.path.dirname(p)])));m = m or not has_mfs and sys.modules.setdefault('google', types.ModuleType('google'));mp = (m or []) and m.__dict__.setdefault('__path__',[]);(p not in mp) and mp.append(p) | |
# ... |
This file contains 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
from bottle import Bottle | |
app = Bottle() | |
@app.route(['/hello', '/']) | |
def hello(): | |
return "Hello World!" | |
@app.route("/_ah/health") | |
def _ah_health(): | |
return "ok" |
This file contains 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 webapp2 | |
from models.user import User | |
webapp2_config = { | |
'webapp2_extras.auth': { | |
'cookie_name': 'sid', | |
'user_model': User, | |
}, | |
'webapp2_extras.sessions': { | |
'secret_key': 'your secret session key', |
This file contains 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
// Realm | |
RealmResults<User> results = realm.where(User.class).findAll(); | |
// SQLite | |
sqliteDatabase.query(TABLE, null, null, null, null, null, null); |
This file contains 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
<activity-alias | |
android:name=".LaunchActivity" | |
android:targetActivity=".MainActivity" | |
> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity-alias> |
This file contains 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
* Add a ViewPager.OnPageChangeListener that will forward events to this TabLayout. | |
* Populate the TabLayout's tabs from the ViewPager's PagerAdapter. | |
* Set our TabLayout.OnTabSelectedListener which will forward selected events to the ViewPager |
This file contains 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
/** | |
* Opaque value, changes when persisted zen mode configuration changes. | |
* | |
* @hide | |
*/ | |
public static final String ZEN_MODE_CONFIG_ETAG = "zen_mode_config_etag"; |
This file contains 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 static class PrefsFragment extends PreferenceFragment { | |
// リファレンスにはこう書いてありますが、 | |
/* | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
// Load the preferences from an XML resource | |
addPreferencesFromResource(R.xml.preferences); |
This file contains 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
class MyCallback extends ConnectivityManager.NetworkCallback { | |
@Override | |
public void onAvailable(Network network) { | |
// 接続されたときに呼ばれる | |
super.onAvailable(network); | |
// ConnectivityManagerのstaticメソッドでアプリ(プロセス)全体のネットワークを設定します。 | |
// networkの中身を確認してから設定してもいいでしょう。 | |
boolean a = ConnectivityManager.setProcessDefaultNetwork(network); |
NewerOlder