Click here to Skip to main content
15,886,689 members

Null exception in pass bundles string between activities from service

shanalikhan asked:

Open original thread
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;
}
Tags: Java, Mobile Apps (Android)

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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