• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Android CustomListView getView() getting nullpointerexception

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[package com.live2support;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Timer;
import java.util.TimerTask;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View.OnClickListener;

import android.view.View;
import android.view.ViewGroup;



import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;


public class BaseActivity extends Activity {

private ListView list =null;
private NotificationManager mNotificationManager;

private final int NOTIFICATION_ID = 1010;
private Timer timer = new Timer();
private String response;
protected Dialog m_ProgressDialog;
String[] operatorList,operatorDetail,operatordetail,tempoperatordata;
String[] noofvisitors,opt;
private static final String DEB_TAG = "Error Message";
public static ArrayList<String> SessionText,IPText,DurationText;
private ArrayList<String> StatusText,NoOfVisit,ButtonText;
private int sizeoflist;
private String IP;
Context context;
public static String from,sessionid,id,text,iptext,status;
private int position,noofchat;
private boolean IsSoundEnable,IsChatOnly;
private Button logout;
private CustomAdapter adapter;
NotificationManager notificationManager;



final HashMap<String, String> postParameters = new HashMap<String, String>();
private String url;

private Handler handler;





private void TimerMethod()
{
//This method is called directly by the timer
//and runs in the same thread as the timer.

//We call the method that will work with the UI
//through the runOnUiThread method.
this.runOnUiThread(Timer_Tick);

}

private Runnable Timer_Tick = new Runnable() {
public void run() {

//This method runs in the same thread as the UI.

//Do something to the UI thread here
getVisitorDetailFromServer();




try {
Log.i("UPDATE", "Handler called");
// searchAdapter = getFeed(URL);

//handler.postDelayed(this, 3000);

} catch(Exception e) {
Log.e("UPDATE ERROR", e.getMessage());
}



}
};





@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.visitor);

list = (ListView) findViewById(R.id.list01);

logout = (Button) findViewById(R.id.btnlogout);

//list.setTextFilterEnabled(true);

//list.clearChoices();





//-----------------Making the object of arrayList----------------

SessionText = new ArrayList<String>();
IPText = new ArrayList<String>();
DurationText = new ArrayList<String>();
StatusText = new ArrayList<String>();
NoOfVisit = new ArrayList<String>();
ButtonText = new ArrayList<String>();

Bundle extras = getIntent().getExtras();
if (extras != null) {
IsSoundEnable = Controls.IsSoundEnable;
IsChatOnly = Controls.IsChatOnly;
IsSoundEnable = extras.getBoolean("IsSoundOnly", Controls.IsSoundEnable);
IsChatOnly= extras.getBoolean("IsCOnlyhat", Controls.IsChatOnly);
extras.getString("From");
position=extras.getInt("Position");


}



}



@Override
protected void onStart() {

super.onStart();

//------------Getting the visitor detail-------------------------


//getVisitorDetailFromServer();
// adapter = new CustomAdapter(BaseActivity.this);
timer.schedule(new TimerTask() {
public void run() {
TimerMethod();
}

}, 0, 3000);



/*handler = new Handler();
updater = new Runnable() {

public void run() {

/*
* Update the list
*/

/* getVisitorDetailFromServer();




try {
Log.i("UPDATE", "Handler called");
// searchAdapter = getFeed(URL);

handler.postDelayed(this, 3000);

} catch(Exception e) {
Log.e("UPDATE ERROR", e.getMessage());
}

}

};

updater.run();*/








//---------------When user click on logout button-----------------------------------


logout.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
logoutFromServer();


}



});


}




//----------------------------Getting the detail from server of monitoring window-------------------------


private void getVisitorDetailFromServer() {
// TODO Auto-generated method stub




url = "http://sa.live2support.com/cpn/wz1-allonlineu.php?";
postParameters.put("adminid",Main.loginId.getText().toString());
postParameters.put("sid",Main.siteId.getText().toString());
postParameters.put("nvar","Y");
postParameters.put("conly", "N");


Runnable searchThread = new Runnable(){

public void run() {
// TODO Auto-generated method stub

try {

response = CustomHttpClient.executeHttpPost1(url,postParameters);

Log.i(DEB_TAG, "Requesting to server"+response);
//CustomHttpClient.getResponseInString(response );

//System.out.println("Output of httpResponse:"+response);

String result = response;
result = response;

String delimiter1 = "<ln>";
String delimiter = "<fld>";

operatorDetail = result.split(delimiter1);
System.out.println("firstresponse================"+operatorDetail[0]);
for(int i=0;i<operatorDetail.length;i++){

operatorList = operatorDetail[i].split(delimiter);
//if(operatorDetail[i].length()<=1) return;

SessionText.add(operatorList[0]);
IPText.add(operatorList[1]);
DurationText.add(operatorList[4]);
StatusText.add(operatorList[3]);
NoOfVisit.add(operatorList[2]);
ButtonText.add(operatorList[6]);





//System.out.println("value of iptext is"+IPText.get(i));




}



operatorDetail=null;
operatorList=null;
SessionText = null;
IPText =null;
DurationText=null;
StatusText=null;
NoOfVisit=null;
ButtonText=null;




operatorDetail = result.split(delimiter1);

SessionText = new ArrayList<String>();
IPText = new ArrayList<String>();
DurationText = new ArrayList<String>();
StatusText = new ArrayList<String>();
NoOfVisit = new ArrayList<String>();
ButtonText = new ArrayList<String>();




//--------Getting the size of the list---------------------

sizeoflist = operatorDetail.length;




} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(response!=null){



runOnUiThread(new Runnable() {

public void run() {
// TODO Auto-generated method stub
playsound3();
noofchat =0;

list.setAdapter(new CustomAdapter(BaseActivity.this));
list.getDrawingCache(false);
list.invalidateViews();
list.setCacheColorHint(Color.TRANSPARENT);
list.requestFocus(0);
list.setSelected(false);
//adapter.notifyDataSetChanged();
// list.getAdapter().notifyAll();


if(IsChatOnly==false){
TimerTask timerTask = new TimerTask()
{
@Override
public void run()
{

//triggerNotification();
//playsound();

}
};
timer.schedule(timerTask, 3000);
}
else{

playsound();
}



}


});
}

else {

ShowAlert();
}


}
};

Thread thread = new Thread(null, searchThread, "MagentoBackground");
thread.start();




}

@Override
public void onDestroy()
{

list.setAdapter(null);
super.onDestroy();
}


//--------------------When internet connection is failed show alert

private void ShowAlert() {
// TODO Auto-generated method stub
AlertDialog.Builder builder = new AlertDialog.Builder(this);
final AlertDialog alert = builder.create();
alert.setTitle("Live2Support");
alert.setMessage("Internet Connection failed");
alert.setButton("OK", new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
//startActivity(new Intent(CreateAccount.this,CreateAccount.class));
alert.dismiss();

}
});

alert.show();
}

//--------------------Play sound when notification occurs-------------------

private void playsound() {
// TODO Auto-generated method stub

MediaPlayer mp = MediaPlayer.create(this, R.raw.newvisitsound);

mp.start();

}

//------------------------Getting the notification of no.of visitor on the site---------------------------

private void triggerNotification() {
// TODO Auto-generated method stub
CharSequence title = "No Of visitors";
CharSequence message = "New visit";
NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.icon, noofvisitors[0], System.currentTimeMillis());
notification.flags |= Notification.FLAG_AUTO_CANCEL;


Intent notificationIntent = new Intent(this, L2STest.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

notification.setLatestEventInfo(BaseActivity.this, title, noofvisitors[0], pendingIntent);
notificationManager.notify(NOTIFICATION_ID, notification);
playsound4();

}

public void completed() {
//remove the notification from the status bar
mNotificationManager.cancel(NOTIFICATION_ID);
}







private void playsound4() {
// TODO Auto-generated method stub
MediaPlayer mp = MediaPlayer.create(this, R.raw.newvisitsound);

mp.start();

}



//-----------------Logout from server--------------------

private void logoutFromServer() {
// TODO Auto-generated method stub
final String url = "http://sa.live2support.com/cpn/wz-adminout.php?";

final HashMap<String, String> postParameters = new HashMap<String, String>();

postParameters.put("adminid",Main.loginId.getText().toString());
postParameters.put("sid",Main.siteId.getText().toString());

Runnable searchThread = new Runnable(){

public void run() {
// TODO Auto-generated method stub

try {
response = CustomHttpClient.executeHttpPost1(url,postParameters);

Log.i(DEB_TAG, "Requesting to server"+response);
//CustomHttpClient.getResponseInString(response );

System.out.println("Output of httpResponse:"+response);





} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(response!=null){

runOnUiThread(new Runnable() {

public void run() {
// TODO Auto-generated method stub
// notificationManager.cancelAll();

System.out.println(response);
showAlert1();
Log.e(DEB_TAG, response);
//System.exit(0);
Intent intent = new Intent(BaseActivity.this,Main.class);
startActivity(intent);
//closeHandler();

}





});
}

// m_ProgressDialog.dismiss();





}


};

Thread thread = new Thread(null, searchThread, "MagentoBackground");
thread.start();
//m_ProgressDialog = ProgressDialog.show(Visitors.this,
// "Please wait...", "Retrieving data ...", true);





}

public void closeHandler() {
// TODO Auto-generated method stub

handler.post(new QuitLooper());

}

class QuitLooper implements Runnable
{
@Override
public void run()
{
Looper.myLooper().quit();
}
}

//----------------------Logout alert when user click on logout button------------------


private void showAlert1() {
// TODO Auto-generated method stub
int duration = Toast.LENGTH_SHORT;
Context context = getApplicationContext();
CharSequence text = "You have Successfully logout.";
Toast toast = Toast.makeText(context, text, duration);
toast.setGravity(Gravity.TOP|Gravity.LEFT, 200, 200);
toast.show();
}



//-------------------Play sound3 when any new user visit----------------


private void playsound3() {
// TODO Auto-generated method stub
MediaPlayer mp = MediaPlayer.create(this, R.raw.newvisitors);

mp.start();

}


//------------------The adapter class------------------------------


private class CustomAdapter extends BaseAdapter {
private LayoutInflater mInflater=null;
private Activity activity;



public CustomAdapter(Context context) {
mInflater = LayoutInflater.from(context);
this.notifyDataSetChanged();



}



public int getCount() {
return sizeoflist;
}

public Object getItem(int position) {
return position;
}

public long getItemId(int position) {
return position;
}

public View getView(final int position, View convertView, ViewGroup parent) {
final ViewHolder holder;
if (convertView == null) {

convertView = mInflater.inflate(R.layout.row1, null);
holder = new ViewHolder();
holder.IP = (TextView) convertView.findViewById(R.id.ip);
holder.duration = (TextView) convertView.findViewById(R.id.duration);
holder.status =(TextView) convertView.findViewById(R.id.status);
holder.noOfVisit = (TextView) convertView.findViewById(R.id.NoOfvisit);
holder.invite =(Button)convertView.findViewById(R.id.btnjoin);
holder.deny = (Button) convertView.findViewById(R.id.btndeny);
//holder.accept = (Button) convertView.findViewById(R.id.btnaccept);


holder.deny.setVisibility(View.INVISIBLE);

holder.invite.setId(position);


convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();

}


String result = response;

String delimiter = "<fld>";
String delimiter1 = "<ln>";
String delimiter2 = "<blk>";
String delimiter3 = "<fld><fld><blk>";
operatorDetail = result.split(delimiter1);
String[] operatorlist = result.split(delimiter3);
noofvisitors = operatorlist[1].split(delimiter2);

//System.out.println("no of visitor================"+noofvisitors[0]);

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

//System.out.println("Operator res=============="+operatorDetail[i]);


operatorList = operatorDetail[i].split(delimiter);
//System.out.println("Operator res=============="+operatorList[1]);

operatorlist = result.split(delimiter2);

SessionText.add(operatorList[0]);
IPText.add(operatorList[1]);
DurationText.add(operatorList[4]);
StatusText.add(operatorList[3]);
NoOfVisit.add(operatorList[2]);
ButtonText.add(operatorList[6]);



/*if(StatusText.get(position).equalsIgnoreCase("chat request")){
holder.deny.setVisibility(View.VISIBLE);
holder.invite.setText("Accept");
//holder.accept.setText("Accept");
/*holder.accept.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
holder.invite.setText("Join");
holder.deny.setVisibility(View.INVISIBLE);
//chatRequest(IPText.get(position), SessionText.get(position));
}
});*/

//}
//else{
holder.invite.setText("Invite");
holder.deny.setVisibility(View.INVISIBLE);
// //holder.accept.setVisibility(View.INVISIBLE);
//}



holder.invite.setText("Invite");
holder.deny.setVisibility(View.INVISIBLE);


if(holder.invite.getText().equals("Join")){

holder.invite.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub

chatRequest(iptext,sessionid);
}
});
}


holder.IP.setText(IPText.get(position));
holder.duration.setText(DurationText.get(position));
holder.status.setText(StatusText.get(position));
holder.noOfVisit.setText(NoOfVisit.get(position));


//---------------------When user click on invite Button---------------------


holder.invite.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
callToServer(SessionText.get(position));
}
});



//-----------------------------When user click on deny button------------------------

holder.deny.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
refuseToServer(sessionid);
holder.deny.setVisibility(View.INVISIBLE);
}




});



}



System.out.println("no of visitor================"+noofvisitors[0]);




convertView.setOnClickListener(new OnClickListener(){

public void onClick(View v) {
Intent i=new Intent(BaseActivity.this,VisitorDetail.class);
i.putExtra("ID", id);
i.putExtra("Position",position);
i.putExtra("From", from);
i.putExtra("SessionText", SessionText.get(position));
i.putExtra("IPTEXT",IPText.get(position));
startActivity(i);
}});
//startService();
return convertView;
}


class ViewHolder {
TextView IP;
TextView duration;
Button deny;
TextView status;
TextView noOfVisit;
Button invite;
Button accept;
}
}

//-------------------when status change change button text---------------------

private String changeButtonText(String status) {
// TODO Auto-generated method stub

if(status.equalsIgnoreCase("chat")){

if(status.equalsIgnoreCase("chatting")){

status = "Join";

}


}
if(status.equalsIgnoreCase(Main.loginId.getText().toString())){
status = "Join";
}

if(status.equalsIgnoreCase("Chat Request")){
status = "Accept";
}
else{
status = "Invite";
}
return status;

}


//------------------Play sound when user click on invite button-------------------------

private void playSound2() {
// TODO Auto-generated method stub
MediaPlayer mp = MediaPlayer.create(this, R.raw.invite);
if(IsSoundEnable){
mp.start();
}
}



//------------When user click on deny button---------------------


private void refuseToServer(String sessionid) {
// TODO Auto-generated method stub
final String url = "http://sa.live2support.com/cpn/wz-action.php?";

final HashMap<String, String> postParameters = new HashMap<String, String>();

postParameters.put("action","refuse");
postParameters.put("csesid", sessionid);


postParameters.put("sid",Main.siteId.getText().toString());
postParameters.put("adminid",Main.loginId.getText().toString());


Runnable searchThread = new Runnable(){

public void run() {
// TODO Auto-generated method stub

try {
response = CustomHttpClient.executeHttpPost1(url,postParameters);

Log.i(DEB_TAG, "Requesting to server"+response);
//CustomHttpClient.getResponseInString(response );


System.out.println("Deny Chat response:"+response);


System.out.println("Deny chat Success"+IP);


} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(response!=null){

runOnUiThread(new Runnable() {

public void run() {
// TODO Auto-generated method stub

System.out.println("response================="+IP);

showAlert(IP);

}



});
}


}


};

Thread thread = new Thread(null, searchThread, "MagentoBackground");
thread.start();

}



//---------------------When user click on invite button-----------------------


private void callToServer(String session) {
// TODO Auto-generated method stub

final String url = "http://sa.live2support.com/cpn/wz-action.php?";

final HashMap<String, String> postParameters = new HashMap<String, String>();

postParameters.put("action","cinvt");
postParameters.put("csesid", session);

postParameters.put("sid",Main.siteId.getText().toString());
postParameters.put("adminid",Main.loginId.getText().toString());


Runnable searchThread = new Runnable(){

public void run() {
// TODO Auto-generated method stub

try {
response = CustomHttpClient.executeHttpPost1(url,postParameters);

Log.i(DEB_TAG, "Requesting to server"+response);
//CustomHttpClient.getResponseInString(response );


System.out.println("Output of httpResponse:"+response);

IP = response;
System.out.println("the resultant ip ===================="+IP);


} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(response!=null){

runOnUiThread(new Runnable() {

public void run() {
// TODO Auto-generated method stub
playSound2();

System.out.println("response================="+IP);

showAlert(IP);

}



});
}


}


};

Thread thread = new Thread(null, searchThread, "MagentoBackground");
thread.start();

}

//------------------Show invitation alert----------------------

private void showAlert(String ip) {
// TODO Auto-generated method stub
int duration = Toast.LENGTH_SHORT;
Context context = getApplicationContext();
CharSequence text = "Invitation sent to "+ip;
Toast toast = Toast.makeText(context, text, duration);
toast.setGravity(Gravity.TOP|Gravity.LEFT, 50, 50);
toast.show();
}


//-----------------When in response we get the chat request--------------------------

private void chatRequest(String iptext, String sessionid) {
// TODO Auto-generated method stub

final String url = "http://sa.live2support.com/cpn//wz1-adc.php?";

final HashMap<String, String> postParameters = new HashMap<String, String>();


postParameters.put("csesid", sessionid);
postParameters.put("ipaddr", iptext);

postParameters.put("sid",Main.siteId.getText().toString());
postParameters.put("adminid",Main.loginId.getText().toString());
postParameters.put("join", "Y");


Runnable searchThread = new Runnable(){

public void run() {
// TODO Auto-generated method stub

try {
response = CustomHttpClient.executeHttpPost1(url,postParameters);

Log.i(DEB_TAG, "Requesting to server"+response);
//CustomHttpClient.getResponseInString(response );


System.out.println("Output of httpResponse:"+response);

IP = response;
System.out.println("the resultant ip ===================="+IP);


} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(response!=null){

runOnUiThread(new Runnable() {

public void run() {
// TODO Auto-generated method stub
playSound2();

System.out.println("response================="+response);

showAlert(IP);

}



});
}

}


};

Thread thread = new Thread(null, searchThread, "MagentoBackground");
thread.start();

}



//--------------When user back from activity--------------------


/*@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
finish();
return true;
}
return super.onKeyDown(keyCode, event);
}*/

}
Actually i am working on a livechat application i am making a monitoring window for which i am getting new data each after 3 seconds and i have to show this data in a listview.i am using this class for this purpose where i am doing wrong until sometime my app is working fine but after someitme is is being crashed and showing nullpointer exception in getview mehtod where i am adding data to the list.
,my logcat looks like this


02-24 18:56:56.600: E/AndroidRuntime(546): FATAL EXCEPTION: main
02-24 18:56:56.600: E/AndroidRuntime(546): java.lang.NullPointerException
02-24 18:56:56.600: E/AndroidRuntime(546): at com.live2support.BaseActivity$CustomAdapter.getView(BaseActivity.java:673)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.AbsListView.obtainView(AbsListView.java:1315)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.ListView.makeAndAddView(ListView.java:1727)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.ListView.fillDown(ListView.java:652)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.ListView.fillFromTop(ListView.java:709)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.ListView.layoutChildren(ListView.java:1580)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.AbsListView.onLayout(AbsListView.java:1147)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.view.View.layout(View.java:7035)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:909)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.view.View.layout(View.java:7035)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.view.View.layout(View.java:7035)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.view.View.layout(View.java:7035)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.view.View.layout(View.java:7035)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.view.View.layout(View.java:7035)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.view.View.layout(View.java:7035)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:909)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.view.View.layout(View.java:7035)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.view.View.layout(View.java:7035)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.view.View.layout(View.java:7035)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.view.View.layout(View.java:7035)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.os.Handler.dispatchMessage(Handler.java:99)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.os.Looper.loop(Looper.java:123)
02-24 18:56:56.600: E/AndroidRuntime(546): at android.app.ActivityThread.main(ActivityThread.java:4627)
02-24 18:56:56.600: E/AndroidRuntime(546): at java.lang.reflect.Method.invokeNative(Native Method)
02-24 18:56:56.600: E/AndroidRuntime(546): at java.lang.reflect.Method.invoke(Method.java:521)
02-24 18:56:56.600: E/AndroidRuntime(546): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-24 18:56:56.600: E/AndroidRuntime(546): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-24 18:56:56.600: E/AndroidRuntime(546): at dalvik.system.NativeStart.main(Native Method)
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Neetika,

Can you paste your code inside code tags please, it becomes easier to read.

 
neetika porwal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes sure
 
neetika porwal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In which line are you getting NPE?
 
neetika porwal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

nullpointexception i am getting at the point
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What code do you have in this line?

BaseActivity.java:673 (line#673).
 
neetika porwal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting error at this point point sometime at firstline or second or any?

SessionText.add(operatorList[0]);
IPText.add(operatorList[1]);
DurationText.add(operatorList[4]);
StatusText.add(operatorList[3]);
NoOfVisit.add(operatorList[2]);
ButtonText.add(operatorList[6]);

and sometimes start of loop

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

i am getting the response but when come at this point getting exception i check it many times.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A probable cause may be, operatorDetail is null, and reason for this may be the response does not contain the delimiters. So, if before you start the loop, if you put a check



This might also help you the debug the problem. Putting some break points might also help and execute the code in debug mode might also help.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another small thought. The response you are getting seems like in xml format, correct me if I am wrong. And if that is the case, why don't you use standard xml parsers like SAX,DOM etc, using this you will be able to get rid of those delimiters, and I guess it becomes easier to debug and execution is faster as well.
 
neetika porwal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes,i know this that i can use the standard standard xml parsers like SAX,DOM etc but i am recieving the response different i am getting the response like this...


thats why i am using parsing Technic like that.Can anyone help me.
 
neetika porwal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I check for (operatorDetail!=null) check also but my problem is not solved.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


If I am not very wrong, your problem is happening within the above block. Why don't you put a break point in the first line of this code block, and execute the code in debug mode to see if any value is null.
 
neetika porwal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i check it by using breakpoint the response i am getting correct and i print the method result again 2 i am getting nullPointerexeption at the point

logcat view like following........



and the change that i made in the class like this........

 
neetika porwal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What i do exactly i am unable to understand the exception getting at the lines




sometimes any of these point


SessionText.add(operatorList[0]);
IPText.add(operatorList[1]);
DurationText.add(operatorList[4]);
StatusText.add(operatorList[3]);
NoOfVisit.add(operatorList[2]);
ButtonText.add(operatorList[6]);

holder.IP.setText(IPText.get(position));
holder.duration.setText(DurationText.get(position));
holder.status.setText(StatusText.get(position));
holder.noOfVisit.setText(NoOfVisit.get(position));
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In that case you may put a break point when the loop starts.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Replace your this code
==================================
operatorDetail=null;
operatorList=null;
SessionText = null;
IPText =null;
DurationText=null;
StatusText=null;
NoOfVisit=null;
ButtonText=null;

operatorDetail = result.split(delimiter1);

SessionText = new ArrayList<String>();
IPText = new ArrayList<String>();
DurationText = new ArrayList<String>();
StatusText = new ArrayList<String>();
NoOfVisit = new ArrayList<String>();
ButtonText = new ArrayList<String>();
=====================================
With Following Code
=====================================
operatorDetail=null;
operatorList=null;
SessionText.clear();
IPText.clear();
DurationText.clear();
StatusText.clear();
NoOfVisit.clear();
ButtonText.clear();

operatorDetail = result.split(delimiter1);
=====================================


 
neetika porwal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got solved my problem thanks you all............
 
neetika porwal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

neetika porwal wrote:

 
neetika porwal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

neetika porwal wrote:

 
reply
    Bookmark Topic Watch Topic
  • New Topic