Scan + Map facilitating in Shipping and Logistics Services - Huawei Developers

You are probably a shipping and logistics company and your services require you to manage the flow of product delivery. You are trying your best to make sure that the products you handle, are transported from the purpose of origin to destination safely. You are trying to find ways to reinforce your services to cater to your customers better. QR Codes are the need of time as QR Codes store information which is easily scan-able with a smartphone and don't need you to put in any cost-intensive set-QR Codes store information. In fact, a QR Code can store up to 7,089 numeric or 2,953 alphanumeric characters.
Being a Shipping & Logistics Service, you need to keep an eye on goods at various stages during transit for which you do not need to regularly call the fellow operators or track the goods information and delivery status. QR Codes help both shipping and logistics do it easily. Once you place them on the packaging, operators can scan them at various stages of the transit from the warehouse to the delivery destination.
With Scan & Map Kit in your Business App, you can easily keep a track of the delivery packages. From scanning to get information, delivery status, delivery destination, and the directions to guide the Deliveryman to the destination.
Huawei Scan Kit:
HUAWEI Scan Kit scans and parses all major 1D and 2D barcodes and generates QR codes, helping you quickly build barcode scanning functions into your apps. Scan Kit automatically detects, magnifies, and recognizes barcodes from a distance, and is also able to scan a very small barcode in the same way.
Huawei Map Kit:
Huawei Map kit allows can easily integrate map-based functions into your apps and make location-based services work better for you.
Pre-Requisites
1. Integrate HMS Core in project
2. Enable Scan and Map Kit from AGC Console
3. Add agconnet-service.json file in the app level directory
1. Add Dependencies & Permission:
1.1: Add the following dependencies in the app level build.gradle file:
Code:
dependencies {
//Map
implementation 'com.huawei.hms:maps:5.0.3.302'
//Scan
implementation 'com.huawei.hms:scan:1.2.2.300'
}
1.2: Add the following permissions in the AndroidManifest.xml:
Code:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!--Camera permission-->
<uses-permission android:name="android.permission.CAMERA" />
<!--File reading permission-->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
2. Add Layout Files:
2.1: Add the activity_main.xml layout file in the layout folder of the res. This is the layout view of the Main Activity of the in the application, contains a Recyclerview to display the arraylist.
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview_parcels"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/_5sdp"
android:stackFromBottom="true" />
</RelativeLayout>
2.2: Add the activity_details.xml layout file in the layout folder of the res. This is the layout view of the Details Activity of the in the application, which contains the Textviews and a Mapview.
Code:
<?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:layout_gravity="center"
android:background="@color/white"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/parcel_details"
android:textStyle="bold"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:gravity="center"
android:textColor="@color/teal_200"
android:textSize="@dimen/_14sdp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/parcelid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textSize="@dimen/_14sdp"/>
<TextView
android:id="@+id/parcelname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textSize="@dimen/_14sdp"/>
<TextView
android:id="@+id/parcelcontact"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textSize="@dimen/_14sdp"/>
<TextView
android:id="@+id/parcellocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textSize="@dimen/_14sdp"/>
<TextView
android:id="@+id/parcelstatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="@dimen/_14sdp"
android:layout_marginBottom="@dimen/_20sdp"/>
<com.huawei.hms.maps.MapView
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraTargetLat="51"
map:cameraTargetLng="10"
map:cameraZoom="8.5"
map:mapType="normal"
map:uiCompass="true"
map:uiZoomControls="true" />
</LinearLayout>
</LinearLayout>
2.3: Add the activity_scan.xml layout file in the layout folder of the res. This is the layout view of the Details Activity of the in the application, which contains the Surfaceview for the camera preview and an ImageView for a customize scanning rectangular area.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:my_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- customize view for camera preview -->
<FrameLayout
android:id="@+id/rim"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#C0C0C0">
<SurfaceView
android:id="@+id/surfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
<!-- customize scanning rectangle -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_centerHorizontal="true"
android:background="#FF000000"
android:alpha="0.1" />
<ImageView
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_centerInParent="true"
android:layout_centerHorizontal="true"
android:background="@drawable/scanningframe" />
</RelativeLayout>
</RelativeLayout>
2.4: Add the cardview_parcel.xml layout file in the layout folder of the res. This is the layout view for the items of Recyclerview in the Main Activity of the application, which contains the Cardview to display Textviews & Imageviews.
Code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:card_view="http://schemas.android.com/tools"
android:padding="@dimen/_3sdp">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:orientation="horizontal"
android:background="@color/white"
card_view:cardCornerRadius="5dp"
card_view:cardElevation="4dp"
card_view:cardUseCompatPadding="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/linearclick_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:background="@color/white"
android:orientation="horizontal"
android:weightSum="10">
<TextView
android:id="@+id/serial_no"
android:layout_width="0dp"
android:layout_height="match_parent"
android:gravity="center"
android:layout_weight="1.5"
android:padding="@dimen/_5sdp"
android:background="@color/purple_200"
android:textColor="@color/black"
android:textSize="@dimen/_11sdp"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="7.5"
android:padding="@dimen/_5sdp"
android:gravity="center"
android:id="@+id/linearmid"
android:orientation="vertical"
android:weightSum="10">
<TextView
android:id="@+id/parcelid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@color/black" />
<TextView
android:id="@+id/parcelname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black" />
<TextView
android:id="@+id/parcelcontact"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black" />
<TextView
android:id="@+id/parcellocation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black" />
<TextView
android:id="@+id/parcelstatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="end">
<ImageView
android:layout_marginEnd="@dimen/_10sdp"
android:layout_width="@dimen/_20sdp"
android:layout_height="@dimen/_20sdp"
android:scaleType="centerCrop"
android:id="@+id/cameraBtn"
android:visibility="invisible"
android:background="@drawable/ic_camera"/>
<ImageView
android:layout_width="@dimen/_20sdp"
android:layout_height="@dimen/_20sdp"
android:layout_toEndOf="@id/cameraBtn"
android:scaleType="centerCrop"
android:id="@+id/locationBtn"
android:background="@drawable/ic_location"/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</RelativeLayout>
3. Add Classes
3.1: Add the MainActivity.java file in the App. This class extends AppCompatActivity and implements the Callback Interface of Parcel Adapter to handle views inside the adapter.
Code:
public class MainActivity extends AppCompatActivity implements ParcelsAdapter.CallbackInterface {
List<ParcelsModal> parcelsModalList;
RecyclerView mRecyclerView;
ParcelsAdapter parcelsAdapter;
public static final int SCAN_START_CODE = 001;
private static final int SCAN_CODE = 002;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
parcelsModalList = new ArrayList<ParcelsModal>();
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
mRecyclerView = (RecyclerView) findViewById(R.id.recyclerview_parcels);
mRecyclerView.setLayoutManager(layoutManager);
// Add Data to list
parcelsModalList.add(new ParcelsModal("00001", "John Atkinson", "123456789", "40.716124, -74.001884","Delivered"));
parcelsModalList.add(new ParcelsModal("00002", "Mark Bennett", "123456789", "40.712188, -73.997378","Delivered"));
parcelsModalList.add(new ParcelsModal("00003", "Jack Brooks", "123456789", "40.717588, -74.010403","Not Delivered"));
parcelsModalList.add(new ParcelsModal("00004", "Alice John", "123456789", "40.715188, -73.995078","Not Delivered"));
parcelsModalList.add(new ParcelsModal("00005", "Julie Berk", "123456789", "40.713588, -74.013303","Not Delivered"));
parcelsAdapter = new ParcelsAdapter(MainActivity.this, (ArrayList<ParcelsModal>) parcelsModalList);
mRecyclerView.setAdapter(parcelsAdapter);
parcelsAdapter.notifyDataSetChanged();
}
//To Handle Callback
@Override
public void onHandleSelection(String text) {
ActivityCompat.requestPermissions(
this,
new String[]{Manifest.permission.CAMERA, Manifest.permission.READ_EXTERNAL_STORAGE},
SCAN_START_CODE);
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (permissions == null || grantResults == null || grantResults.length < 2 || grantResults[0] != PackageManager.PERMISSION_GRANTED || grantResults[1] != PackageManager.PERMISSION_GRANTED) {
return;
}
if (requestCode == SCAN_START_CODE) {
//start your activity for scanning barcode
Intent newIntent = new Intent(this, ScanActivity.class);
this.startActivityForResult(newIntent, SCAN_CODE);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//receive result after your activity finished scanning
super.onActivityResult(requestCode, resultCode, data);
if (resultCode != RESULT_OK || data == null) {
return;
}
//Get Code from QR
if (requestCode == SCAN_CODE) {
HmsScan hmsScan = data.getParcelableExtra(ScanActivity.SCAN_RESULT);
if (hmsScan != null && !TextUtils.isEmpty(hmsScan.getOriginalValue())) {
processData(hmsScan.getOriginalValue());
}
}
}
//To Handle Adapter callback data in Activity
private void processData(String value){
for (ParcelsModal modal : parcelsAdapter.getDataAdapterList()) {
//Update date at your Server Here
if(modal.getParcel_id().equals(value)){
modal.setParcel_dilvery_status("Delivered");
Toast.makeText(this, "Parcel Delivered", Toast.LENGTH_SHORT).show();
break; // No need to run the remaining loop
}
}
parcelsAdapter.notifyDataSetChanged();
}
}

How many types of barcode can Huawei Scan kit generates ?

Related

[Q] Help needed for my Android App from my uni football team.

Hey Good People,
Basically I have a Radio Group with two radio buttons, one of them is labelled RUN and the other is labelled PASS.
Just underneath this I also have a check-box labelled "Pass Complete"
Question: How do I disable the check-box when RUN radio button is selected (so it can't be selected) and enable it while the PASS radio button is selected?
Any help constructing some type of IF statement
XML
<RadioGroup
android:id="@+id/runandpass"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
androidrientation="horizontal">
<RadioButton
android:id="@+id/radiobuttonrun"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="RUN" android:layout_weight="50"/>
<RadioButton
android:id="@+id/radiobuttonpass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PASS"
android:layout_weight="50"/>
</RadioGroup>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
androidrientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="50"
android:text="" />
<CheckBox
android:id="@+id/checkBoxcmpltpass"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pass Complete"
android:layout_weight="6"/>
</LinearLayout>
JAVA
package com.aces.acesfootballuk;
import android.app.Activity;
import android.os.Bundle;
public class CoachesPage extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.coachespage);
}
};

[Q] Need Help with an application and coding

I have created a new xml file in the res>layout forlder called tabs.xml. It has the following code:
<?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"
androidrientation="vertical" >
<TabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
androidrientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/Network"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Channel Type:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<RadioButton
android:id="@+id/urbanButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:text="Urban" />
<RadioButton
android:id="@+id/suburbanButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/urbanButton1"
android:layout_alignBottom="@+id/urbanButton1"
android:layout_centerHorizontal="true"
android:text="SubUrban" />
<RadioButton
android:id="@+id/ruralButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/suburbanButton2"
android:layout_alignBottom="@+id/suburbanButton2"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:text="Rural" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/urbanButton1"
android:text="Characteristics of Channel:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="@+id/suburbanButton2"
android:layout_below="@+id/textView2"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView3"
android:layout_toLeftOf="@+id/ruralButton3"
android:text="Manual Override" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/power"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/Connectivity"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/Offline"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
</FrameLayout>
</LinearLayout>`enter code here`
</TabHost>
</LinearLayout>
Now i also have a andoid activity_main.xml in the same folder which i added nothing to it. i also created a java file called Tabs.Java and put it in the src folder under src>com.example.qosmetre>Tabs.Java with the following code
package com.example.qosmetre;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class Tabs extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tabs);
}
}
Now my question is, when i run my app on the terminal or in debugging mode, how come nothing is showing up but a blank screen? Like i want the tabs to show up first thing with all the stuff underneath them as shown in the code above. Also how would i import a library for scatter plotting data that would be in my app?
I need to know where and what files to put what code in because im just a beginner and i dont know too much so ill need big guidence.
Thanks again in advance.

[Q] HELP ME - Eclipse Android (ADT)

So, Im making a Root Checker app for android with Root Tools.
However, when I run it on a device, the button doesnt do anything... Here's my code:
MainActivity.java
Code:
package com.gs2012.rootchecker;
import com.stericson.RootTools.RootTools;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.app.Activity;
import android.view.Menu;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
Button aButton;
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
aButton = (Button) this.findViewById(R.id.button1);
final TextView hasbusybox = (TextView) this.findViewById(R.id.TextView03);
final TextView hassu = (TextView) this.findViewById(R.id.TextView02);
final TextView hasroot = (TextView) this.findViewById(R.id.TextView04);
aButton.setOnClickListener(new OnClickListener() {
public void onClick1(final View v) {
// Here is where we tell it what to do
if (RootTools.isBusyboxAvailable())
{
hasbusybox.setText("Busybox OK");
}
else
{
hasbusybox.setText("NOT OK");
}
if (RootTools.isRootAvailable())
{
hassu.setText("SU OK");
}
else {
{
hassu.setText("NOT OK");
}
if (RootTools.isAccessGiven())
{
hasroot.setText("ROOT OK");
}
else
{
hasroot.setText("NOT OK");
}
}
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
;}});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
activity_main.xml
Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Click the button to check for root access."
android:textAppearance="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="47dp"
android:text="CHECK NOW" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/button1"
android:layout_marginTop="80dp"
android:text="Busybox installed:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView2"
android:layout_alignBottom="@+id/textView2"
android:layout_marginLeft="16dp"
android:layout_toRightOf="@+id/textView2"
android:text="NOT CHECKED"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView2"
android:layout_marginTop="29dp"
android:layout_toLeftOf="@+id/textView3"
android:text="SU installed:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/TextView03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/TextView01"
android:layout_marginTop="28dp"
android:layout_toLeftOf="@+id/textView3"
android:text="Has root access:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/TextView04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/TextView03"
android:layout_alignBottom="@+id/TextView03"
android:layout_alignLeft="@+id/textView3"
android:text="NOT CHECKED"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/TextView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/TextView03"
android:layout_alignLeft="@+id/TextView04"
android:text="NOT CHECKED"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/TextView05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Click the button to check for root access."
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/textView1"
android:text="By Gnm Software 2012"
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
Bump
Sent from my GT-S6310N using xda app-developers app

[Q] listView has unwanted rows in some phones

I have created an android program which contains listview. Emulator and my phone (Samsung Galaxy S) shows like;
-see First Attachment (1.png)
But when I open my program in Samsung Note 3, it shows like;
-see Second Attachment (2.png)
It likes 2 empty rows(empty but their colors dark blue) and 1 real list view item. 2 empty rows, 1 real item, 2 empty rows, 1 real item ....
I tried each of item in listview. I removed each one and it does not solve my problem. And some bigger screen phones have same issue. How can i solve it?
my xml:
Code:
<RelativeLayout
android:id="@+id/tabTT"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:id="@+id/tabTT_icon"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Team Tactics"
android:id="@+id/tabTT_main_text"
android:textSize="13sp"
android:textStyle="bold"
android:textColor="#800000"
android:visibility="invisible"
android:layout_centerHorizontal="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tabTT_main_second"
android:textSize="12sp"
android:textColor="#000000"
android:visibility="invisible"
android:layout_below="@id/tabTT_main_text"
android:layout_centerHorizontal="true"/>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tabTT_listView"
android:clickable="true"
android:layout_below="@id/tabTT_main_second"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tabTT_ImageView"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tabTT_textView_name"
android:textSize="13sp"
android:textStyle="bold"
android:textColor="#000000"
android:layout_marginLeft="68dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tabTT_textView_subName"
android:textSize="12sp"
android:layout_below="@id/tabTT_textView_name"
android:textColor="#000000"
android:layout_marginLeft="68dp"/>
<ProgressBar
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/tabTT_ProgressBar"
android:layout_below="@id/tabTT_textView_subName"
android:layout_toRightOf="@id/tabTT_ImageView"
android:progressDrawable="@drawable/progress_bar"
android:visibility="invisible"
style="?android:attr/progressBarStyleHorizontal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tabTT_textView_percentage"
android:layout_centerHorizontal="true"
android:layout_below="@id/tabTT_textView_subName"
android:textColor="#800000"/>
</RelativeLayout>
my adapter:
Code:
public static class TTAdapter extends ArrayAdapter<Achievement> {
public TTAdapter(Context context, ArrayList<Achievement> users) {
super(context, 0, users);
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
Achievement user = getItem(position);
// Check if an existing view is being reused, otherwise inflate the view
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.list_item_ach, parent, false);
}
convertView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Achievement clicked = getItem(position);
if(clicked.progressFloatSecond!=-1){
Toast.makeText(getContext(), "Left: " + NumberFormat.getNumberInstance(Locale.US).format(clicked.progressFloatSecond - clicked.progressFloatFirst), Toast.LENGTH_SHORT).show();
}
else Toast.makeText(getContext(), "One-Time Mission!", Toast.LENGTH_SHORT).show();
}
});
TextView name = (TextView) convertView.findViewById(R.id.tabTT_textView_name);
TextView subName = (TextView) convertView.findViewById(R.id.tabTT_textView_subName);
ImageView imVi = (ImageView)convertView.findViewById(R.id.tabTT_ImageView);
ProgressBar progBar = (ProgressBar) convertView.findViewById(R.id.tabTT_ProgressBar);
TextView percentageFloat = (TextView) convertView.findViewById(R.id.tabTT_textView_percentage);
DecimalFormat df = new DecimalFormat("##.##");
name.setText(user.name);
subName.setText(user.subName);
imVi.setImageResource(user.picInt);
progBar.setVisibility(View.INVISIBLE);
percentageFloat.setVisibility(View.INVISIBLE);
if(user.progressFloatSecond!=-1){
progBar.setVisibility(View.VISIBLE);
progBar.setMax(user.progressFloatSecond);
progBar.setProgress(user.progressFloatFirst);
percentageFloat.setText(df.format(user.progressFloat) + " %");
percentageFloat.setVisibility(View.VISIBLE);
}
return convertView;
}
}
By the way, in application there are 6 different list views and all have same problem. I write here only one listview's code.

Fetch the Covid-19 cases list using the Volley Library in Patient Tracking Android app (Kotlin) – Part 3

{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Introduction
In this article, we can learn how to get the number of Covid-19 affected cases world-wide as well as India wise. Here, we have used the Volley as Library to fetch the data using the REST API to display in the application. In this application, we can find the total cases affected, number of cases recovered and number of deaths on world wide as well as in India can find the state wise list also.
So, I will provide a series of articles on this Patient Tracking App, in upcoming articles I will integrate other Huawei Kits.
If you are new to this application, follow my previous articles.
https://forums.developer.huawei.com/forumPortal/en/topic/0201902220661040078
https://forums.developer.huawei.com/forumPortal/en/topic/0201908355251870119
Requirements
1. Any operating system (MacOS, Linux and Windows).
2. Must have a Huawei phone with HMS 4.0.0.300 or later.
3. Must have a laptop or desktop with Android Studio, Jdk 1.8, SDK platform 26 and Gradle 4.6 and above installed.
4. Minimum API Level 24 is required.
5. Required EMUI 9.0.0 and later version devices.
How to integrate HMS Dependencies
1. First register as Huawei developer and complete identity verification in Huawei developers website, refer to register a Huawei ID.
2. Create a project in android studio, refer Creating an Android Studio Project.
3. Generate a SHA-256 certificate fingerprint.
4. To generate SHA-256 certificate fingerprint. On right-upper corner of android project click Gradle, choose Project Name > Tasks > android, and then click signingReport, as follows.
Note: Project Name depends on the user created name.
5. Create an App in AppGallery Connect.
6. Download the agconnect-services.json file from App information, copy and paste in android Project under app directory, as follows.
7. Enter SHA-256 certificate fingerprint and click Save button, as follows.
Note: Above steps from Step 1 to 7 is common for all Huawei Kits.
8. Add the below maven URL in build.gradle(Project) file under the repositories of buildscript, dependencies and allprojects, refer Add Configuration.
Java:
maven { url 'http://developer.huawei.com/repo/' }
classpath 'com.huawei.agconnect:agcp:1.6.0.300'
9. Add the below plugin and dependencies in build.gradle(Module) file.
Java:
apply plugin: id 'com.huawei.agconnect'
// Huawei AGC
implementation 'com.huawei.agconnect:agconnect-core:1.6.0.300'
// Recyclerview
implementation 'androidx.recyclerview:recyclerview:1.2.1'
// Volley Library
implementation 'com.android.volley:volley:1.2.1'
10. Now Sync the gradle.
11. Add the required permission to the AndroidManifest.xml file.
Java:
<uses-permission android:name="android.permission.INTERNET" />
Let us move to development
I have created a project on Android studio with empty activity let us start coding.
In the Home.kt activity to find the business logic for button item click.
Code:
class Home : AppCompatActivity(), HomeAdapter.ItemListener {
private lateinit var recyclerView: RecyclerView
private lateinit var arrayList: ArrayList<HomeIcons>
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home)
recyclerView = findViewById(R.id.recyclerview_list)
arrayList = ArrayList()
arrayList.add(HomeIcons("Patient", "Add details", R.drawable.add_icon, "#00b0ff"))
arrayList.add(HomeIcons("Covid-19", "Covid Cases", R.drawable.covid_icon, "#00b0ff"))
val adapter = HomeAdapter(applicationContext, arrayList, this)
recyclerView.adapter = adapter
recyclerView.layoutManager = GridLayoutManager(this, 2)
recyclerView.setHasFixedSize(true)
}
override fun onItemClick(item: Int) {
when(item ) {
0 -> {val intent = Intent(this, PatientActivity::class.java)
startActivity(intent)
}
1 -> {val intent = Intent([email protected], CovidActivity::class.java)
startActivity(intent)
}
}
}
}
In the CovidActivity.kt activity to find the business logic for cases list data.
Java:
class CovidActivity : AppCompatActivity() {
lateinit var worldCases: TextView
lateinit var worldRecovered: TextView
lateinit var worldDeaths: TextView
lateinit var countryCases: TextView
lateinit var countryRecovered: TextView
lateinit var countryDeaths: TextView
lateinit var stateRV: RecyclerView
lateinit var stateRVAdapter: CasesAdapter
lateinit var stateList: List<CasesData>
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_covid)
worldCases = findViewById(R.id.txt_world_cases)
worldRecovered = findViewById(R.id.txt_world_recovered)
worldDeaths = findViewById(R.id.txt_world_deaths)
countryCases = findViewById(R.id.txt_india_cases)
countryRecovered = findViewById(R.id.txt_india_recovered)
countryDeaths = findViewById(R.id.txt_india_deaths)
stateRV = findViewById(R.id.recyclerview_cases)
stateList = ArrayList<CasesData>()
getStateInfo()
getWorldInfo()
}
private fun getStateInfo(){
val url = "https://api.rootnet.in/covid19-in/stats/latest"
val queue = Volley.newRequestQueue([email protected])
val request = JsonObjectRequest(Request.Method.GET,url, null, { response ->
try{
val dataObj = response.getJSONObject("data")
val summaryObj = dataObj.getJSONObject("summary")
val cases: Int = summaryObj.getInt("total")
val recovered:Int = summaryObj.getInt("discharged")
val deaths: Int = summaryObj.getInt("deaths")
countryCases.text = cases.toString()
countryRecovered.text = recovered.toString()
countryDeaths.text = deaths.toString()
val regionalArray = dataObj.getJSONArray("regional")
for(i in 0 until regionalArray.length()){
val regionalObj = regionalArray.getJSONObject(i)
val stateName: String = regionalObj.getString("loc")
val cases: Int = regionalObj.getInt("totalConfirmed")
val deaths: Int = regionalObj.getInt("deaths")
val recovered: Int = regionalObj.getInt("discharged")
val stateCases = CasesData(stateName,recovered,deaths,cases)
stateList = stateList+stateCases
}
stateRVAdapter = CasesAdapter(stateList)
stateRV.layoutManager = LinearLayoutManager(this)
stateRV.adapter = stateRVAdapter
}
catch (e:JSONException){
e.printStackTrace()
}
}, {error -> Toast.makeText(this, "Failed to get Data", Toast.LENGTH_SHORT).show()
}
)
queue.add(request)
}
private fun getWorldInfo(){
val url = "https://corona.lmao.ninja/v3/covid-19/all"
val queue = Volley.newRequestQueue([email protected])
val request = JsonObjectRequest(Request.Method.GET,url, null, { response ->
try{
val worldCases1: Int = response.getInt("cases")
val worldRecovered1:Int = response.getInt("recovered")
val worldDeaths1: Int = response.getInt("deaths")
worldRecovered.text = worldRecovered1.toString()
worldCases.text = worldCases1.toString()
worldDeaths.text = worldDeaths1.toString()
}
catch (e:JSONException){
e.printStackTrace()
}
}, {error ->
Toast.makeText(this, "Failed to get Data", Toast.LENGTH_SHORT).show()
}
)
queue.add(request)
}
}
Create a CasesData.kt data class to list the data variables.
Java:
data class CasesData(
val state: String,
val recovered: Int,
val deaths: Int,
val cases: Int
)
Create a CasesAdapter.kt adapter class to hold the list.
Java:
class CasesAdapter (private val stateList: List<CasesData>): RecyclerView.Adapter<CasesAdapter.ViewHolder>(){
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CasesAdapter.ViewHolder {
val view: View = LayoutInflater.from(parent.context).inflate(R.layout.cases_list, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val stateData = stateList[position]
holder.stateCases.text = stateData.cases.toString()
holder.stateName.text = stateData.state.toString()
holder.stateDeaths.text = stateData.deaths.toString()
holder.stateRecovered.text = stateData.recovered.toString()
}
override fun getItemCount(): Int {
return stateList.size
}
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val stateName = itemView.findViewById<View>(R.id.txt_state) as TextView
val stateCases = itemView.findViewById<View>(R.id.txt_state_cases) as TextView
val stateDeaths = itemView.findViewById<View>(R.id.txt_state_deaths) as TextView
val stateRecovered = itemView.findViewById<View>(R.id.txt_state_recovered) as TextView
}
}
In the activity_home.xml we can create the UI screen for Recycler View item buttons.
Java:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="8dp"
android:paddingRight="8dp"
tools:context=".Home">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
android:visibility="gone"
android:layout_marginTop="40dp"
android:clickable="true"
tools:ignore="MissingConstraints">
<ImageView
android:id="@+id/img_android"
android:layout_width="155dp"
android:layout_height="180dp"
android:layout_marginRight="15dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="20dp"
android:src="@drawable/add_icon"/>
<ImageView
android:id="@+id/img_hms_icon"
android:layout_width="155dp"
android:layout_height="180dp"
android:layout_marginRight="5dp"
android:layout_marginTop="20dp"
android:src="@drawable/doctor_icon"/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview_list"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
In the activity_covid.xml we can create the UI screen for cases list.
Java:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".covid.CovidActivity">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
app:cardCornerRadius="3dp"
app:cardElevation="3dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginTop="0dp"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="100dp"
android:layout_marginLeft="25dp"
android:layout_marginBottom="25dp"
android:src="@drawable/world_icon" >
</ImageView>
<TextView
android:layout_width="match_parent"
android:layout_height="80dp"
android:text="World Wide Record"
android:textAlignment="center"
android:layout_marginBottom="30dp"
android:textSize="18sp"
android:padding="3dp"
android:textColor="@color/black"
android:layout_marginTop="25dp">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal"
android:weightSum="3" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
tools:ignore="Suspicious0dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Cases"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textSize="15sp"
android:padding="4dp"
android:textStyle="bold"
android:textColor="@color/black">
</TextView>
<TextView
android:id="@+id/txt_world_cases"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Number of Cases"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textSize="12sp"
android:padding="4dp"
android:textColor="@color/blue">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
tools:ignore="Suspicious0dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Recovered"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textSize="15sp"
android:padding="4dp"
android:textStyle="bold"
android:textColor="@color/black">
</TextView>
<TextView
android:id="@+id/txt_world_recovered"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Number of Recovered"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textSize="12sp"
android:padding="4dp"
android:textColor="@color/green">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
tools:ignore="Suspicious0dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Deaths"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textSize="15sp"
android:padding="4dp"
android:textStyle="bold"
android:textColor="@color/black">
</TextView>
<TextView
android:id="@+id/txt_world_deaths"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Number of Deaths"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textSize="12sp"
android:padding="4dp"
android:textColor="@color/red">
</TextView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
app:cardCornerRadius="3dp"
app:cardElevation="3dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginTop="0dp"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="100dp"
android:layout_marginLeft="25dp"
android:layout_marginBottom="25dp"
android:src="@drawable/india_icon" >
</ImageView>
<TextView
android:layout_width="match_parent"
android:layout_height="80dp"
android:text="India Record"
android:textAlignment="center"
android:layout_marginBottom="30dp"
android:textSize="18sp"
android:padding="3dp"
android:textColor="@color/indianblue"
android:layout_marginTop="25dp">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal"
android:weightSum="3" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
tools:ignore="Suspicious0dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Cases"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textSize="15sp"
android:padding="4dp"
android:textStyle="bold"
android:textColor="@color/black">
</TextView>
<TextView
android:id="@+id/txt_india_cases"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="4dp"
android:text="Number of Cases"
android:textAlignment="center"
android:textColor="@color/blue"
android:textSize="12sp">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
tools:ignore="Suspicious0dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Recovered"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textSize="15sp"
android:padding="4dp"
android:textStyle="bold"
android:textColor="@color/black">
</TextView>
<TextView
android:id="@+id/txt_india_recovered"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Number of Recovered"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textSize="12sp"
android:padding="4dp"
android:textColor="@color/green">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
tools:ignore="Suspicious0dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Deaths"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textSize="15sp"
android:padding="4dp"
android:textStyle="bold"
android:textColor="@color/black">
</TextView>
<TextView
android:id="@+id/txt_india_deaths"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Number of Deaths"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textSize="12sp"
android:padding="4dp"
android:textColor="@color/red">
</TextView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview_cases"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
In the cases_list.xml we can create the UI screen for customized items of state wise cases.
Java:
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
app:cardCornerRadius="3dp"
app:cardElevation="3dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/txt_state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="State Name"
android:textSize="18sp"
android:padding="5dp"
android:layout_margin="3dp"
android:textColor="@color/teal_700">
</TextView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="65dp"
android:orientation="horizontal"
android:weightSum="3" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Cases"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textSize="15sp"
android:padding="4dp"
android:textStyle="bold"
android:textColor="@color/black">
</TextView>
<TextView
android:id="@+id/txt_state_cases"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Number of Cases"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textSize="12sp"
android:padding="4dp"
android:textColor="@color/blue">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Recovered"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textSize="15sp"
android:padding="4dp"
android:textStyle="bold"
android:textColor="@color/black">
</TextView>
<TextView
android:id="@+id/txt_state_recovered"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Number of Recovered"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textSize="12sp"
android:padding="4dp"
android:textColor="@color/green">
</TextView>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Deaths"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textSize="15sp"
android:padding="4dp"
android:textStyle="bold"
android:textColor="@color/black">
</TextView>
<TextView
android:id="@+id/txt_state_deaths"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Number of Deaths"
android:textAlignment="center"
android:layout_gravity="center_horizontal"
android:textSize="12sp"
android:padding="4dp"
android:textColor="@color/red">
</TextView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
Demo
Tips and Tricks
1. Make sure you are already registered as Huawei developer.
2. Set minSDK version to 24 or later, otherwise you will get AndriodManifest merge issue.
3. Make sure you have added the agconnect-services.json file to app folder.
4. Make sure you have added SHA-256 fingerprint without fail.
5. Make sure all the dependencies are added properly.
Conclusion
In this article, we have learned that how to get the number of Covid-19 affected cases world-wide as well as India wise. Here, we have used the Volley as Library to fetch the data using the REST API to display in the application. In this application, we can find the total cases affected, number of cases recovered and number of deaths on worldwide as well as in India can find the state wise list also.
I hope you have read this article. If you found it is helpful, please provide likes and comments.
Reference
Volley Library - https://www.geeksforgeeks.org/volle... library,interfering with the user experience.

Categories

Resources