Click here to Skip to main content
11,799,282 members (77,333 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Java Android

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

following is the code for service :
public Integer thumbs =;
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

		LayoutInflater inflator = ((Activity)con).getLayoutInflater();
		view = inflator.inflate(R.layout.activity_device_info, arg2,false);
	TextView deviceName = (TextView)view.findViewById(;
            ImageView img = (ImageView)view.findViewById(;
            img.setOnClickListener(new OnClickListener() {
		public void onClick(View arg0) {
			Intent in = new Intent((Activity)con  , FileManagerActivity.class);
			Log.e("DEVICEADAPTOR", "Moved");
    return view;
while im getting information as null exception in next activity as :
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(, menu);
    Log.e("FILEMANAGERACTIVITY", "starting");
    Bundle bn = null;
    a= getIntent().getIntExtra("Nmbr", 0);
    Log.e("FILEMANAGERACTIVITY", String.valueOf(a));
    return true;
Posted 1-Jun-13 11:44am
Sergey Alexandrovich Kryukov at 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?
shanalikhan at 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 at 2-Jun-13 11:56am
Did you locate in what line the exception was thrown?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Solved Myselft



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

  Print Answers RSS
0 OriginalGriff 473
1 CPallini 410
2 Richard MacCutchan 319
3 phil.o 244
4 Kornfeld Eliyahu Peter 205
0 OriginalGriff 2,475
1 Maciej Los 1,860
2 KrunalRohit 1,496
3 CPallini 1,465
4 Richard MacCutchan 1,149

Advertise | Privacy | Mobile
Web01 | 2.8.151002.1 | Last Updated 8 Jun 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100