• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Read data from Google Sheets

Hello everyone,
I have been trying since days to read data from Google Sheets into a list view. I was referring to tutorials from Crazy Coders Club. The write operation works well, however, the read operation either shows nothing or makes the app crash. I am adding below my codes, and I will be grateful if someone could help me figure out the problem.

Here are my spreadsheet link: https://docs.google.com/spreadsheets/d/1Bccu6dyOIV5lF-be_95LDYkdFEdqtBYKhNDE97nv_Ss/edit?usp=sharing

and Google Scripts link: https://script.google.com/d/1HdmpUP...1uOzcZclQNm0mlxDK1QeKlz-9KFo/edit?usp=sharing

XML:
Code:
<?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">


    <ListView
        android:id="@+id/lv_items"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

XML (leaderboard_item):
Code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
    xmlns:app="http://schemas.android.com/apk/res-auto">


    <LinearLayout
        android:layout_width="350dp"
        android:layout_height="90dp"
        android:orientation="horizontal"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.1">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="80dp"
            android:background="#EAE8E8">

            <TextView
                android:id="@+id/username"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="50dp"
                android:fontFamily="@font/league_spartan_bold"
                android:text="TextView"
                android:textColor="@color/colorPrimaryDark"
                android:textSize="20sp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/score"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginEnd="20dp"
                android:fontFamily="@font/sanchez"
                android:text="TextView"
                android:textColor="@color/colorTextDark"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="1.0"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:id="@+id/rank"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="20dp"
                android:fontFamily="@font/sanchez"
                android:text="1"
                android:textColor="@color/colorTextDark"
                android:textSize="20sp"
                android:textStyle="bold"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

        </androidx.constraintlayout.widget.ConstraintLayout>
    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Java Code:
Code:
package com.example.aquatricity;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.RetryPolicy;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;

public class Leaderboard extends AppCompatActivity {

    ProgressDialog loading;
    ListView listview;
    ListAdapter adapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_leaderboard);

        listview = (ListView) findViewById(R.id.lv_items);

        getUsers();

    }


    private void getUsers() {

        loading =  ProgressDialog.show(this,"Loading","please wait",false,true);

        StringRequest stringRequest = new StringRequest(Request.Method.GET, "https://script.google.com/macros/s/AKfycbzvfbIcBrm6UXpK3xphHor2azlk1dZxar28_6z8PFI7xDyNq4xnQ-m4Gs80A3Y8ZspT_Q/exec?action=getUsers",
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        parseItems(response);
                    }
                },

                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {

                    }
                }
        );

        int socketTimeOut = 50000;
        RetryPolicy policy = new DefaultRetryPolicy(socketTimeOut, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);

        stringRequest.setRetryPolicy(policy);

        RequestQueue queue = Volley.newRequestQueue(this);
        queue.add(stringRequest);

    }


    private void parseItems(String jsonResposnce) {

        ArrayList<HashMap<String, String>> list = new ArrayList<>();

        try {
            JSONObject jobj = new JSONObject(jsonResposnce);
            JSONArray jarray = jobj.getJSONArray("Users");
            HashMap<String, String> user = new HashMap<>();

            for (int i = 0; i < jarray.length(); i++) {

                JSONObject jo = jarray.getJSONObject(i);

                String displayName = jo.getString("displayName");
                String email = jo.getString("emailAddress");
                String pass = jo.getString("password");
                String phoneNumber = jo.getString("phoneNumber");
                String score = jo.getString("score");
                String rank = jo.getString("rank");
                String house = jo.getString("household");



                user.put("displayName", displayName);
                user.put("rank", rank);
                user.put("score",score);

                list.add(user);

            }
            
        } catch (JSONException e) {
            e.printStackTrace();
        }

        adapter = new SimpleAdapter(this,list,R.layout.leaderboard_item,
                new String[]{"displayName","rank","score"},new int[]{R.id.username,R.id.rank,R.id.score});


        loading.dismiss();
    }
}

Help Hard resetting/Powerwashing an android device

^this.

If you don't know about factory reset protection, it's an anti-theft measure introduced in 2015. The logic behind it is to make theft less attractive: previously someone could steal a phone, reset it then use or sell it. With FRP the phone can't be used after a reset unless you enter the previous login details, making it less worthwhile for a thief to steal in the first place (if a legitimate owner wants to sell the phone they need to remove their account from it before doing a reset). This does however make it very important that you don't forget your password: by definition if there is any way for you to bypass this then a thief can use that too, which would make the whole thing pointless. Hence it is designed not to have any workarounds, and where a bug does allow a way the manufacturer tends to patch it as soon as they become aware.

Apple introduced a similar system a bit before Android, so I'm afraid it's been a long time since resetting has been a solution to a forgotten password on any phone.

Allow an app to download another app?

It's odd, I never gave permission for Boinc to download and run executables, and yet it can. Maybe I did years ago, since I used a Samsung utility to copy all the apps from my old Android 7 phone to this one, so it might have copied permissions. But there definitely aren't permissions for Boinc to do that when I look at it's info.

Yoyo said they had no interest in fixing it two years ago when someone else complained. I guess they designed it badly and got away with it until android got more secure. boinc is not the easiest thing to work with, they probably tried and failed to get it's own downloader to function. When you say "Boinc team" - actually that's one guy, a volunteer out of work programmer. nothing ever gets fixed.

My Android 4 phone is absolutely awful at security, it's full of Adware and nothing even rooting gets rid of it, every single time I turn on the screen a browser opens with an advert. Probably (knowing the source) it was injected into the OS at the factory.

Round air vent smartphone holders??

I'm trying to find an air vent holder for my wife's 2017 Toyota Yaris but have had no luck so far. I've purchased 2 on Amazon and neither fit her vents. Do any of you have a Yaris or another model with round air vents and have a mount that fit them? Just to clear, it's not that the shape of the air vent that's the issue. It's the fact that the fins are round/curved as well.

Mark in San Diego

Auto Text Backup?

I prefer exporting messages directly to internal storage or MicroSD, so I can browse them on the PC and avoid vendor lock-in. With root, the directory they are stored in, presumably somewhere in /data/, would be directly accessible.
It would be, but you'd find they were in a database rather than a set of files, so you'd need the right tool to browse them that way.

One reason backup tools don't just make a copy of the database is that it's not reliably portable between different models of phone. The other will presumably be that like any SMS app they access the messages through an API rather than having direct access to the database (which is owned by a dedicated message storage app rather than any individual SMS app).

Chrome, Nest, Google home, Administrator, Android

As far as I know, no spam type text or the like could do what you describe.

However, there ARE apps that could be used to do sort of the same thing.

This requires the app to be installed on your device as well as the other persons, and it takes time to set it all up- in other words, this person would need time alone with your device.

https://f-droid.org/en/packages/tranquvis.simplesmsremote/

Sony Xperia SL

Hi, can you transfer photos from your old Sony Xperia SL to the computer via USB cable? You can try it as below:
1: Connect your Sony Xperia SL to the computer via a USB cable.
2: Slide down from the top of the screen and tap the USB connection, select Media transfer mode (MTP).
3: On your computer, go to file explorer and click your Sony Xperia device. Find and open the "DCIM" folder that stores your photos.
4: Drag and drop the photos you want to transfer them from Sony Xperia to computer.
Hope this will be your help.

Calendar Sync

Presumably these events were not synced, just stored in a "local" calendar on the phone. If they were synced to some account you need to set up the same account on the new phone.

If they are unsynced then you need to install a calendar app on the old phone which has the option to export them. Not all do, though in my calendar app collection Business Calendar has this, don't know about Google Calendar as I don't use it. This will export the selected calendar's events to either an ics or a vcs file, can't remember which. Copy the file to the new phone and import it there (may also need to install an app that supports import/export there).

The other option would be to move all of the events to a synched calendar, but I don't know whether you have a bulk way of doing that - otherwise it would be very tedious if you have many events.

[SOLVED} Pedestal sink stopper stuck

Personally, I think baths are gross. I already felt that way anyway, but after re-watching an episode of "Extreme Cheapskates," it was reinforced big-time! This one family (two adults and two teenagers) all use the same bath water, one after the other, starting with Dad. By the time they showed the youngest in the tub--and the mother's voiceover was saying 'we don't have cooties, we never get that dirty....' the water was BROWN. Brown!! Ugh.

Oh, and it's COLD water. They don't believe in using heat, either.

I used to bathe my Great Danes in the tub, but using the hand-held shower, i.e., not filling up/stopping the tub. In the summer, they were bathed outside (in the sizzling 100+ degree heat). I haven't taken a bath in decades....nor do I want to! The next time I have someone here who can fix the trip lever, maybe I'll ask them to do that. Or not. I don't really care. I've lived in this house for 16 years now, and haven't needed to use the tub for bathing since my grandchildren were babies--they're both in double-digits now!
I trimmed a multi million dollar home a few years before retiring. One of the slick things they installed was a pet shower. It was walk in and larger than a tub shower. Not only did it have a hand held shower outlet, it had a number of shower heads that imitated a gentle rain fall.
It had two benches so one could sit while bathing their dog. It was slick!!! I had a Saint Bernard for a decade or so that was a real treat to bathe. He was as big as the tub and left little room to get in there with him and impossible to bathe from outside the tub. When I saw that pet shower I thought how wonderful that would have been back in the day. The German Shepard and the mom and pop Dalmatian weren't a problem and their son begged for a bath.

Looking At Contacts Backup Products

Why bother? Every android contacts app I've ever met has an option to export your contacts. This will write them to a vcard file, which is a standard format understood by any contact management software (so you can load it into any contact management software you have on your computer too). So do an export, copy the file to a computer over USB, job done, no need to purchase anything.

amcrest ash21-b camera question

i got 2 of these cameras the ash21-b cameras and it turns out someone attached to the amcrest app and the other one i managed to get connected but then it failed. and i can't delete them from the app ro amcrest site.

my question is this, does or has anyone here managed to re the firmware on ip cameras s they can be used on computers? as it turns out these are for the app and the cloud service but i'm betting someone has figured out how to root them so the can be re-programmed for some other app fo the computers. these will not run on the amcrest search tool. the search tool see them but will not fully connect to them for computer viewing.

my tiny cam app see them but will not connect enough to the either.

i figure i might as well give ti a try and if they get bricked i'm not out any more than i am now. amcrest will not reset them for me nor will they delete them from there app.

thanks

Filter

Back
Top Bottom