Click here to Skip to main content
15,880,427 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi,

I am getting null pointer exception on passing vales between activities from service.

following is the code for service :
Java
public Integer thumbs = R.drawable.computer;
private Context con=null;
private LstClients clients = null;
private Server ser=null;

public DeviceAdaptor(Context c, Server ser){
	con = c;
	this.ser = ser;
	this.clients= this.ser.Clients();
}

public View getView(int arg0, View view, ViewGroup arg2) {
	// TODO Auto-generated method stub

	if(view==null){
		LayoutInflater inflator = ((Activity)con).getLayoutInflater();
		view = inflator.inflate(R.layout.activity_device_info, arg2,false);

	}
	
	TextView deviceName = (TextView)view.findViewById(R.id.lblDeviceName);
	tmp=arg0;
            deviceName.setText(clients.Name(arg0));
            ImageView img = (ImageView)view.findViewById(R.id.imgDevice);
            img.setImageResource(R.drawable.computer);
            img.setOnClickListener(new OnClickListener() {
		
		@Override
		public void onClick(View arg0) {
		
			ser.FindClients().interact.get(tmp).start();
			Intent in = new Intent((Activity)con  , FileManagerActivity.class);
			in.putExtra("Nmbr",tmp);
			con.startActivity(in);
			Log.e("DEVICEADAPTOR", "Moved");
			
		}
	});
    return view;
}

while im getting information as null exception in next activity as :
C#
public boolean onCreateOptionsMenu(Menu menu) {

    getMenuInflater().inflate(R.menu.file_manager, menu);
    Log.e("FILEMANAGERACTIVITY", "starting");
    Bundle bn = null;
    a= getIntent().getIntExtra("Nmbr", 0);
    Log.e("FILEMANAGERACTIVITY", String.valueOf(a));
    Start();

    return true;
}
Posted
v4
Comments
Sergey Alexandrovich Kryukov 1-Jun-13 22:12pm    
Look at the code sample. It's fool of formatting artifacts and mistakes (starting from "ublic"). Who do you think will have patience to look at it? Besides, what prevents you from just using a debugger and locating the point of throwing the exception?
—SA
shanalikhan 2-Jun-13 3:33am    
please have a look . that was copying mistake. please chk im.onclick event in service only and second class
Sergey Alexandrovich Kryukov 2-Jun-13 11:56am    
Did you locate in what line the exception was thrown?
—SA

1 solution

Solved Myselft

.................\
..............







...................
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900