Skip to content

Instantly share code, notes, and snippets.

Added in Android Jelly Bean (4.1) - API 16 :
Regular (default):
<item name="android:fontFamily">sans-serif</item>
<item name="android:textStyle">normal</item>
Italic:
<item name="android:fontFamily">sans-serif</item>
<item name="android:textStyle">italic</item>
// Gradle Plugin 2.0+
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
// Gradle Plugin 1.5
android {
defaultConfig {
public void navigateToCamera(Uri photoLocalUri, int requestImageCapture) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoLocalUri);
activity.startActivityForResult(intent, requestImageCapture);
}
@Rule
public ActivityTestRule activityRule = new ActivityTestRule<>(
MainActivity.class,
true, // initialTouchMode
false); // launchActivity. False to set intent per method
@Test
public void someTest() {
Intents.init();
onView(withId(R.id.some_id)).perform(click());
Intents.release();
}
@Test
public void shouldSelectImageOnCamera() {
Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, data);
intending(hasAction(MediaStore.ACTION_IMAGE_CAPTURE)).respondWith(result);
onView(withId(R.id.camera)).perform(click());
}
public void shareImage(String text, Uri imageUri) {
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
shareIntent.setType("image/*");
activity.startActivity(Intent.createChooser(shareIntent, text));
}
@Test
public void shouldShareImageFromGallery() {
Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, data);
intending(hasAction(Intent.ACTION_CHOOSER)).respondWith(result);
onView(withId(R.id.share)).perform(click());
intended(allOf(
hasExtras(allOf(
public static Intent getCallingIntent(Context context, ArrayList<GalleryPhoto> imagesOnDevice) {
Intent intent = new Intent(context, GalleryActivity.class);
intent.putParcelableArrayListExtra(EXTRA_IMAGES_ON_DEVICE, imagesOnDevice);
return intent;
}
...
@Test
public void someTest() {
class SpannableTextView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = 0
) : TextView(context, attrs, defStyle) {
fun setSpannableText(vararg texts: SpannableStyle) {
buildWith(breaker = " ", blocks = *texts)
}