Export data to google sheet with android studio : "Unfortunately, My application has stopped"

eligoxp :

i'm trying to apply a tutorial on youtube about posting some data on a google sheet :

https://www.youtube.com/watch?v=GyuJ2GtpZd0

It's really well explained and I did everything same than the guy did, but I don't understand why my app stops... I manage to build it without any problem (I didn't change the layout, I just added the class "HttpRequest").

I don't have any knowledge in java, I just copied the tutorial, here is the code :

package com.example.test;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

import java.net.URLEncoder;

public class MainActivity extends Activity {

    final String myTag = "DocsUpload";



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.i(myTag, "OnCreate()");
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                postData();

            }
        });
        t.start();
    }

    public void postData() {

        String fullUrl = "https://docs.google.com/forms/d/e/1FAIpQLSeADSNYrRj2c8ctLn5Q0M7taM6ayYnykFbp3oZI_xorAt6gKg/formResponse";
        HttpRequest mReq = new HttpRequest();
        String col1 = "Hello";

        String data = "entry.1529019979=" + URLEncoder.encode(col1);
        String response = mReq.sendPost(fullUrl, data);
        Log.i(myTag, response);
    }

}

And here are the errors displayed :

10-28 18:23:35.254 10736-10736/? E/libprocessgroup: failed to make and chown /acct/uid_10057: Read-only file system
10-28 18:23:35.353 10736-10752/? E/Your App Name Here: HttpUtils: java.lang.SecurityException: Permission denied (missing INTERNET permission?)
10-28 18:23:35.354 10736-10752/? E/AndroidRuntime: FATAL EXCEPTION: Thread-602
    Process: com.example.test, PID: 10736
    java.lang.NullPointerException: println needs a message
        at android.util.Log.println_native(Native Method)
        at android.util.Log.i(Log.java:160)
        at com.example.test.MainActivity.postData(MainActivity.java:40)
        at com.example.test.MainActivity$1.run(MainActivity.java:23)
        at java.lang.Thread.run(Thread.java:818)
10-28 18:23:35.694 10736-10753/? E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf
10-28 18:23:35.695 10736-10753/? E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008824

Please, could anyone help me ? I don't understand anything in this report...

Thank you so much!

Md. Asaduzzaman :

You have to add INTERNET permission in your AndroidManifest.xml file

<uses-permission android:name="android.permission.INTERNET" />

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=356868&siteId=1