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
| <?xml version="1.0" encoding="utf-8"?> | |
| <!-- Add this as a debug manifest so the permissions won't be required by your production app --> | |
| <manifest xmlns:android="http://schemas.android.com/apk/res/android"> | |
| <uses-permission android:name="android.permission.WAKE_LOCK" /> | |
| <uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> | |
| </manifest> |
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
| package com.ryanharter.android.util; | |
| import android.content.Context; | |
| import android.content.SharedPreferences; | |
| /** | |
| * Keeps track of the number of app launches, and days since first launch, and | |
| * provides an easy way to determine whether you should show a rating prompt | |
| * or not. | |
| */ |
| /* | |
| * 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 |
This is a short Gist showing how I transmit any uncaught exceptions happening in the Wearable part of my App to the connected Smartphone/Tablet. This is necessary because Android Wear devices are not directly connected to the Internet themselves.
##Wear
| import com.google.auto.value.AutoValue; | |
| import java.lang.annotation.Retention; | |
| import java.lang.annotation.Target; | |
| import static java.lang.annotation.ElementType.TYPE; | |
| import static java.lang.annotation.RetentionPolicy.RUNTIME; | |
| /** | |
| * Marks an {@link AutoValue @AutoValue}-annotated type for proper Gson serialization. | |
| * <p> |
| /* | |
| * 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 |
| SelectionQueryBuilder q = new SelectionQueryBuilder() | |
| .expr("is_awesome", EQ, true) | |
| .expr("money", GT, 50.0f) | |
| .expr("speed", LT, 21.1f) | |
| .or() | |
| .expr("door_number", EQ, 123) | |
| .or().expr( | |
| new SelectionQueryBuilder() | |
| .expr("a", GT, 0) | |
| .expr("a", LT, 100) |
| @Override | |
| protected void setUp() throws Exception { | |
| super.setUp(); | |
| // Create a Context for our content provider that will use the test.* | |
| // database instead of the production database | |
| final String filenamePrefix = "test."; | |
| final RenamingDelegatingContext testDatabaseContext = new RenamingDelegatingContext( | |
| getInstrumentation().getTargetContext(), getInstrumentation() | |
| .getTargetContext(), filenamePrefix); |
| brunql@brunql-desktop:~$ telnet localhost 3636 | |
| Trying ::1... | |
| Trying 127.0.0.1... | |
| Connected to localhost. | |
| Escape character is '^]'. | |
| Lightpack API v1.3 (type "help" for more info) | |
| ? | |
| List of available commands: | |
| apikey, lock, unlock, getstatus, getstatusapi, getprofile, getprofiles, |