Click here to Skip to main content
15,892,809 members
Home / Discussions / Android
   

Android

 
QuestionWhatsapp like messaging app Pin
Munish Kapoor4-Aug-16 2:46
Munish Kapoor4-Aug-16 2:46 
AnswerRe: Whatsapp like messaging app Pin
Richard MacCutchan4-Aug-16 3:37
mveRichard MacCutchan4-Aug-16 3:37 
QuestionRe: What is best Mobile Company? Pin
David Crow4-Aug-16 3:41
David Crow4-Aug-16 3:41 
QuestionAndroid Pin
Member 126664442-Aug-16 9:27
Member 126664442-Aug-16 9:27 
AnswerRe: Android Pin
Richard MacCutchan2-Aug-16 20:33
mveRichard MacCutchan2-Aug-16 20:33 
QuestionI want to create an app connected to the cloud Pin
Member 118283652-Aug-16 2:03
Member 118283652-Aug-16 2:03 
AnswerRe: I want to create an app connected to the cloud Pin
Afzaal Ahmad Zeeshan2-Aug-16 2:07
professionalAfzaal Ahmad Zeeshan2-Aug-16 2:07 
QuestionHow to deal with this NullPointerException Pin
Member 1265737227-Jul-16 17:33
Member 1265737227-Jul-16 17:33 
here is the logcat

Quote:
07-26 19:48:22.594 2618-2618/com.example.example E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.example, PID: 2618
java.lang.NullPointerException: storage == null
at java.util.Arrays$ArrayList.<init>(Arrays.java:38)
at java.util.Arrays.asList(Arrays.java:155)
at android.widget.ArrayAdapter.<init>(ArrayAdapter.java:128)
at com.example.example.CustomList.<init>(CustomList.javaBlush | :O )
at com.example.example.MainActivity1.showJSON(MainActivity1.java:59)
at com.example.example.MainActivity1.access$000(MainActivity1.java:18)
at com.example.example.MainActivity1$1.onResponse(MainActivity1.java:42)
at com.example.example.MainActivity1$1.onResponse(MainActivity1.java:39)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:67)
at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)




Java
MainActivity1.java



Java
package com.example.example;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

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

public class MainActivity1 extends AppCompatActivity implements View.OnClickListener {

public static final String JSON_URL = "https://drive.google.com/file/d/0B12MlCDj9SefUS1TbW5LVmc0OGM/view?usp=sharing";

private Button buttonGet;

private ListView listView;

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

    buttonGet = (Button) findViewById(R.id.buttonGet);
    buttonGet.setOnClickListener(this);
    listView = (ListView) findViewById(R.id.listView);
}

private void sendRequest(){

    StringRequest stringRequest = new StringRequest(JSON_URL,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    showJSON(response);
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Toast.makeText(MainActivity1.this,error.getMessage(),Toast.LENGTH_LONG).show();
                }
            });

    RequestQueue requestQueue = Volley.newRequestQueue(this);
    requestQueue.add(stringRequest);
}

private void showJSON(String json){
    ParseJSON pj = new ParseJSON(json);
    pj.parseJSON();
    CustomList cl = new CustomList(this, ParseJSON.ids,ParseJSON.names,ParseJSON.emails);
    listView.setAdapter(cl);
}

@Override
public void onClick(View v) {
    sendRequest();
}
}


Java
CustomList.java


Java
package com.example.example;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;


public class CustomList extends ArrayAdapter<String> {
private String[] ids;
private String[] names;
private String[] emails;
private Activity context;

public CustomList(Activity context, String[] ids, String[] names, String[] emails) {
    super(context, R.layout.list_view_layout, ids);
    this.context = context;
    this.ids = ids;
    this.names = names;
    this.emails = emails;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = context.getLayoutInflater();
    View listViewItem = inflater.inflate(R.layout.list_view_layout, null, true);
    TextView textViewId = (TextView) listViewItem.findViewById(R.id.textViewId);
    TextView textViewName = (TextView) listViewItem.findViewById(R.id.textViewName);
    TextView textViewEmail = (TextView) listViewItem.findViewById(R.id.textViewEmail);

    textViewId.setText(ids[position]);
    textViewName.setText(names[position]);
    textViewEmail.setText(emails[position]);

    return listViewItem;
}
}

AnswerRe: How to deal with this NullPointerException Pin
Richard MacCutchan27-Jul-16 20:41
mveRichard MacCutchan27-Jul-16 20:41 
QuestionRe: How to deal with this NullPointerException Pin
David Crow28-Jul-16 7:24
David Crow28-Jul-16 7:24 
Questionproximity sensor Pin
pranjalisharma23-Jul-16 23:09
pranjalisharma23-Jul-16 23:09 
AnswerRe: proximity sensor Pin
Richard MacCutchan24-Jul-16 1:36
mveRichard MacCutchan24-Jul-16 1:36 
GeneralRe: proximity sensor Pin
pranjalisharma24-Jul-16 3:40
pranjalisharma24-Jul-16 3:40 
GeneralRe: proximity sensor Pin
Richard MacCutchan24-Jul-16 4:32
mveRichard MacCutchan24-Jul-16 4:32 
AnswerRe: proximity sensor Pin
David Crow25-Jul-16 4:31
David Crow25-Jul-16 4:31 
Questionandroid Pin
Member 1264808121-Jul-16 23:54
Member 1264808121-Jul-16 23:54 
SuggestionRe: android Pin
Richard MacCutchan22-Jul-16 0:29
mveRichard MacCutchan22-Jul-16 0:29 
AnswerRe: android Pin
Afzaal Ahmad Zeeshan22-Jul-16 1:23
professionalAfzaal Ahmad Zeeshan22-Jul-16 1:23 
QuestionAndroid developers: is there a better way to get timezon? Pin
Member 1250994720-Jul-16 9:30
Member 1250994720-Jul-16 9:30 
QuestionRe: Android developers: is there a better way to get timezon? Pin
David Crow20-Jul-16 15:04
David Crow20-Jul-16 15:04 
Rant[REPOST] Android developers: is there a better way to get timezon? Pin
Richard Deeming21-Jul-16 3:23
mveRichard Deeming21-Jul-16 3:23 
Questionhow to parse xml data in asmx service please help me Pin
Member 121887768-Jul-16 9:29
Member 121887768-Jul-16 9:29 
AnswerRe: how to parse xml data in asmx service please help me Pin
Super Lloyd10-Jul-16 16:21
Super Lloyd10-Jul-16 16:21 
Questionhow to change audio tempo? Pin
Nikolai Morozov8-Jul-16 9:23
Nikolai Morozov8-Jul-16 9:23 
AnswerRe: how to change audio tempo? Pin
Richard MacCutchan8-Jul-16 22:43
mveRichard MacCutchan8-Jul-16 22:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.