Skip to content

Instantly share code, notes, and snippets.

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

Oren Bochman OrenBochman

🏠
Working from home
  • WMF
  • 04:22 (UTC +03:00)
View GitHub Profile
@OrenBochman
OrenBochman / AdWords-BQ-MCC.js
Last active June 18, 2018 11:18
Import AdWords data into BQ
// Copyright 2016, Google Inc. All Rights Reserved.
//
// 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
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@OrenBochman
OrenBochman / !!save_activity_state.md
Last active August 28, 2021 08:08
Android State - save and restore activity's state in a bundle

Saving and restoring activity state across configuration changes

  1. implement onSaveInstanceState(Bundle state)
  2. implement onRestoreInstanceState(Bundle state)
  • input controlls are saved automatically
  • listview items/position etc need to be saved.
  • to persist for the long term use SQLite db, shared prefrences or a file
@OrenBochman
OrenBochman / 00_Create_parch&posey
Created August 15, 2018 11:33
Creating the database
this gist has the data for this sample db
@OrenBochman
OrenBochman / !!readme.md
Last active September 9, 2018 15:25
reusable fragment

Fragment - reusable

Basic reusable fragment - based on exposing an interface.

@OrenBochman
OrenBochman / !!readme.md
Last active September 9, 2018 15:17
Android dialog with host callbacks

Android dialog with host callbacks

@OrenBochman
OrenBochman / !!Configuration Changes.md
Last active September 8, 2018 06:28
handling configuration changes in fragments and activities

Configuration Changes

getting the cuttent configuration

in an activity:

Configuration config = ContextThemeWrapper.getResources().getConfiguration();

Saving UI state (simple)

Record Audio

@OrenBochman
OrenBochman / RuntimePermissionRequest.java
Last active August 21, 2018 07:11 — forked from davidgassner/RuntimePermissionRequest
ask for permission to make a phone call on android
//Add before making a phone call
if (ActivityCompat.checkSelfPermission(
MainActivity.this, Manifest.permission.CALL_PHONE)
!= PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this,
Manifest.permission.CALL_PHONE)) {
Toast.makeText(MainActivity.this, "I know you said no, but I'm asking again", Toast.LENGTH_SHORT).show();
}
ActivityCompat.requestPermissions(MainActivity.this,
new String[]{Manifest.permission.CALL_PHONE},
@OrenBochman
OrenBochman / !!readme.md
Last active October 5, 2018 18:53
check if network access is avaiable

Network Helper

Note: connectivity broadcasts are no longer sent to inactive apps - to avoid waking 40+ apps on each network change.

  1. check app has network access
  2. schedule a task when network is available...