This test rule is now in the 'test-rules' support repository. Use that one!
https://developer.android.com/reference/android/support/test/rule/ActivityTestRule.html
| /** | |
| * Show the activity over the lockscreen and wake up the device. If you launched the app manually | |
| * both of these conditions are already true. If you deployed from the IDE, however, this will | |
| * save you from hundreds of power button presses and pattern swiping per day! | |
| */ | |
| public static void riseAndShine(Activity activity) { | |
| activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED); | |
| PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE); | |
| PowerManager.WakeLock lock = |
| // your code | |
| apply from: "build-plugins/idea-gradle-sources.gradle" |
This test rule is now in the 'test-rules' support repository. Use that one!
https://developer.android.com/reference/android/support/test/rule/ActivityTestRule.html
| #!/bin/bash | |
| # License for any modification to the original (linked below): | |
| # ---------------------------------------------------------------------------- | |
| # "THE BEER-WARE LICENSE" (Revision 42): | |
| # Sebastiano Poggi wrote this file. As long as you retain this notice you | |
| # can do whatever you want with this stuff. If we meet some day, and you think | |
| # this stuff is worth it, you can buy me a beer in return. | |
| # ---------------------------------------------------------------------------- | |
| prefix=${1-"drawable"} | |
| buckets=( mdpi hdpi xhdpi xxhdpi xxxhdpi ) |
| /* | |
| * Copyright 2014 Chris Banes | |
| * | |
| * 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 |
| /* | |
| * Copyright (C) 2014 The Android Open Source Project | |
| * | |
| * 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 |
| import android.graphics.Bitmap; | |
| import com.google.zxing.BarcodeFormat; | |
| import com.google.zxing.WriterException; | |
| import com.google.zxing.common.BitMatrix; | |
| import com.google.zxing.qrcode.QRCodeWriter; | |
| /** | |
| * This class contains a single method that will generate a QR Code | |
| * with given text, foreground and background color, and dimension of the side |
| public class ExampleActivity extends Activity implements WatchFaceLifecycle.Listener { | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_my_layout); | |
| WatchFaceLifecycle.attach(this, savedInstanceState, this); | |
| } | |
| @Override |
| def toCamelCase(String string) { | |
| String result = "" | |
| string.findAll("[^\\W]+") { String word -> | |
| result += word.capitalize() | |
| } | |
| return result | |
| } | |
| afterEvaluate { project -> | |
| Configuration runtimeConfiguration = project.configurations.getByName('compile') |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.