FAQ

Gradle dependencies (which libraries to include for MyRus)

Android supports a number of libraries that you can include in your app if you want to use the functionality offered. You need to add these libraries to your gradle. Android does not inlcude them as default because they can explode the size of the apk a user downloads -- taking up net bandwidth and memory on your phone; so Question is which libraries should you include in your gradle build.gradle (module: app) file?

We recommned you include the ones below in your MyRuns1 as a default because we know you will use them:

  1. To use any class from "android.support.v4.app" package (e.g. Fragment, FragmentPagerAdapter or FragmentManager), you should add following library to your project dependencies inside app/build.gradle:
  1. And for importing BottomNavigationView class, add:
  1. If you wants to use ConstraintLayout add:
  1. Cropping pictures add
  1. We recommend to use classes from "android.support." package for the project consistency.

Note, you might see that if you start to use an API not included in your current build the Android Studio will complian that its not recognise. You need to find the library and add the dependency to your gradle file.

The gradle build script dependency identifiers for these libraries are as follows:


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.soundcloud.android:android-crop:1.0.1@aar'
}

How many activies and fragments do we implement for MyRuns2?

MyRuns activities vs fragments As I understand it, this is the breakdown of what is implemented as fragments and what is implemented as activities for MyRuns2:


Activities:

Sign in
Edit Profile/Register
Main Activity
Map Activity
Manual Input Activity
Settings Activity

Fragments:

Start
History

How does Android Studio build an apk?

Great question. The build process takes your gradle file and using other files like the Manfiest compiles resources (views, etc), Android Java code (even embedded c other source), packages, external and internal libraries into a APK. Read through the above link to get a deeper understanding of the workflow to create an APK.

With dynanic fragments what is the difference between add() and replace() transactions?

In the code below the transaction method add() is used to add a new to the container. Assuming no other fragment exists the lifecycle runs through the normal set of methods driven by add() and commit().


FragmentTransaction ft = getFragmentManager().beginTransaction();
Fragment newFragment = MyFragment.newInstance("From Arguments");
ft.add(R.id.content, newFragment);
ft.commit();

If we want to replace the existing fragment added above with a new fragment (otherFragment) in the same container then we use the replace() method on the fragment transaction. In terms of the fragment lifecycle the new fragment is created first (onAttach(), onCreate(), etc) and readied, then, the existing fragment executes onPause(), onStop(), etc. And then the new fragment is make visible (through onResume()) after ft.commit() returns..


FragmentTransaction ft = getFragmentManager().beginTransaction();
Fragment otherFragment = MyFragment.newInstance("From Arguments");
ft.replace(R.id.content, otherFragment);
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ft.commit();

For more information on fragments and transaction methods see developers.