NewsWeatherTraffic_Update - ArshadHishamAPM/Aido_NewsWeatherTraffic GitHub Wiki
NewsWeatherTraffic App contains 3 sections,that are
- News
- Traffic
- Weather
In NewsWeatherTraffic App, we changed the packages used by these sections to new versions.in latest android studio 3.6.3 support targetsdkversion and compliesdkversion upto 29.every apk building we are using both compile sdk version and target sdk version is greater than 25.because more than sdk 25 platform support several libraries.on the same way we want to set minimum sdk version to more than 17 because less than 17 sdk version not supporting several packages like map packages. pply plugin: 'com.android.application'
android {
compileSdkVersion 27
// buildToolsVersion "27.1.1"
defaultConfig {
applicationId "com.rathore.newsweathertraffic"
minSdkVersion 22
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
We need to import several libraries to News ,Traffic and Weather to perform its function by adding corresponding packages in build.gradle(app) of NewsWeatherTraffic App.
The packages are:
implementation 'com.google.android.gms:play-services:11.0.4'
implementation 'com.android.volley:volley:1.1.0'
// compile 'com.android.support:design:25.3.1'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.akexorcist:googledirectionlibrary:1.0.5'
implementation 'com.github.bumptech.glide:glide:3.5.2'
// compile 'com.android.support:support-v4:25.0.0'
// compile 'com.android.support:appcompat-v7:25.+'
implementation 'com.google.android.gms:play-services:6.+'
// compile 'com.android.support:recyclerview-v7:25.0.1'
//implementation 'com.intuit.sdp:sdp-android:1.0.4'
// implementation 'de.hdodenhof:circleimageview:1.2.2'
// implementation 'com.android.support:multidex:1.0.1'
implementation 'com.squareup.picasso:picasso:2.4.0'
implementation 'com.google.android.gms:play-services-maps:9.8.0'
// implementation 'com.jakewharton:butterknife:8.4.0'
// annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
// implementation 'com.google.android.gms:play-services:10.0.1'
//noinspection GradleCompatible
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
// implementation 'org.apache.directory.studio:org.apache.commons.io:2.4'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:design:27.1.1'
// implementation 'com.diegocarloslima:fgelv:0.1.+@aar'
// implementation 'com.squareup.retrofit2:retrofit:2.0.2'
// implementation 'com.squareup.retrofit2:converter-gson:2.0.2'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.volley:volley:1.1.1'
In android studio 3.6.3 support both android and androidx libraries.latest is androidx many of our app are created in androidx format.butNewsWeatherTraffic app doesn’t use androidx libraries so my aim is to make android libraries is supported by android studio 3.6.3.
News,Traffic and Traffic
Its activity contain both java file and xml file.in xml file contains some old xml design tags that are not supported by android studio 3.6.3.so i change tag to supported format like.
Xml(toolbar)
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar_home"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ececec"
android:minHeight="?attr/actionBarSize"
app:titleTextColor="@android:color/white">
<!--android:background="?attr/colorPrimary"-->
We must to import toolbar libraries to all activity java files they use toolbar. Only this libraries support toolbar in android ,that is import android.support.v7.widget.Toolbar; we can use import androidx.app.widget.toolbar only in androidx packages.
All these 3 sections we change both xml design tags and import corresponding libraries in its activities. Import libraries: All 3 sections contains several activities, all of these contain corresponding libraries.import the libraries in supported format.here showing only few imports of first activitiy of 3 sections.
News
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
etc…………………………………………………………………….
Traffic
import com.android.volley.toolbox.Volley;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.android.gms.tasks.OnSuccessListener;
etc…………………………………………………………………….
Weather
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
etc…………………………………………………………………….
In Traffic and weather need google api key for your project to support map and add these key in manifest file.
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyA3W_ptuXXWQ9aHp3DHP6US7aVSg92s1Po" />
Generate google api key and restrict this api key to protect from other app. Open the google console with mail id and create project and generate key to add map to app.
https://developers.google.com/maps/documentation/android-sdk/get-api-key refer this link to create and restrict the generted key.
In Traffic have 2 pages one is showing traffic between stanford and palo Alto ,this is we set by default.on other page contain the traffic between the user location and destination.we can switch these pages by there is one button on right_top side.
we enter the destination and press the go button .first we getting the default page after that click the button on right top side to get the traffic between the current location and destination. We are adding more libraries to our project, so enable multidex to support large no of libraries.