This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.testbed.projects.stackoverflow"> | |
<application | |
android:allowBackup="true" | |
android:icon="@mipmap/ic_launcher" | |
android:label="@string/app_name" | |
android:supportsRtl="true" | |
android:theme="@style/AppTheme"> |
This file contains hidden or 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
// It is very easy to subscribe to changes to the battery state, but you can get the current | |
// state by simply passing null in as your receiver. Nifty, isn't that? | |
IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); | |
Intent batteryStatus = this.registerReceiver(null, filter); | |
int chargePlug = batteryStatus.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1); | |
boolean acCharge = (chargePlug == BatteryManager.BATTERY_PLUGGED_AC); | |
if (acCharge) { | |
Log.v(LOG_TAG,“The phone is charging!”); | |
} |
This file contains hidden or 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 class FreeTheWakelockActivity extends ActionBarActivity { | |
public static final String LOG_TAG = "FreeTheWakelockActivity"; | |
TextView mWakeLockMsg; | |
ComponentName mServiceComponent; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_wakelock); |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<RelativeLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:id="@+id/activity_main" | |
android:clipToPadding="false" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:gravity="center" |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
<item android:state_enabled="true" android:state_pressed="true"> | |
<objectAnimator | |
android:duration="@android:integer/config_shortAnimTime" | |
android:propertyName="translationZ" | |
android:valueTo="8dp" | |
android:valueType="floatType" | |
/> | |
</item> |
This file contains hidden or 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
<ripple xmlns:android="http://schemas.android.com/apk/res/android" | |
android:color="?android:colorControlHighlight"> | |
<item> | |
<shape android:shape="rectangle"> | |
<solid android:color="?android:colorAccent"/> | |
</shape> | |
</item> | |
</ripple> |
This file contains hidden or 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
//to reveal a previously invisible view using this effect: | |
void enterReveal() { | |
// previously invisible view | |
final View myView = findViewById(R.id.my_view); | |
// get the center for the clipping circle | |
int cx = myView.getMeasuredWidth() / 2; | |
int cy = myView.getMeasuredHeight() / 2; |
This file contains hidden or 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 PermissionsExample | |
{ | |
public static void getLocationPermission( AppCompatActivity thisActivity ) | |
{ | |
if ( ActivityCompat.checkSelfPermission( thisActivity, android.Manifest.permission.ACCESS_FINE_LOCATION ) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission( thisActivity, android.Manifest.permission.ACCESS_COARSE_LOCATION ) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission( thisActivity, android.Manifest.permission.INTERNET ) != PackageManager.PERMISSION_GRANTED ) | |
{ |
This file contains hidden or 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 class CustomFontTextView extends TextView | |
{ | |
public CustomFontTextView(Context context, AttributeSet attrs, int defStyle) { | |
super(context, attrs, defStyle); | |
init(); | |
} | |
public CustomFontTextView(Context context, AttributeSet attrs) { | |
super(context, attrs); |
This file contains hidden or 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 class MainActivity extends AppCompatActivity | |
{ | |
private ResponseReceiver receiver; | |
@Override | |
protected void onCreate( Bundle savedInstanceState ) | |
{ | |
super.onCreate( savedInstanceState ); | |
setContentView( R.layout.activity_main ); |