Skip to content

Instantly share code, notes, and snippets.

Avatar

Rafael Toledo rafaeltoledo

View GitHub Profile
View build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'org.jacoco:org.jacoco.core:0.8.0'
}
}
View activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">
<EditText
android:id="@+id/name"
android:layout_width="match_parent"
View MainActivity.java
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
View strings.xml
<!-- strings.xml file -->
<resources>
<string name="app_name">Tutorial</string>
<string name="save">Save</string>
<string name="address">Address</string>
<string name="name">Name</string>
</resources>
View activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">
<EditText
android:id="@+id/name"
android:layout_width="match_parent"
View activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
View MainActivity.java
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
Log.d("MA::Action", intent.getAction());
for (String category : intent.getCategories()) {
Log.d("MA::Category", category);
}
View AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.rafaeltoledo.tutorial">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
View AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.rafaeltoledo.tutorial">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
View unit-test-jacoco.groovy
android {
//...
testOptions {
unitTests.all {
jacoco {
includeNoLocationClasses = true
}
}
}