开发者

we can check whether intent.putExtras(key,value) has done or not?

I am working on android. i want to know that whether this is possible to check that following key,value pair has created or not ?

String filename=getIntent().getExtras().getString("FILE_NAME");
text开发者_C百科View_file_name=(TextView)findViewById(R.id.TextView_fileName);
textView_file_name.setText(filename);

before my first programing statement, means before getting the value of FILE_NAME, i want to check whether this key-value pair has build or not ? because i am getting null pointer exception in the case if it is not done before these statement. So i want to know that is any code so i can check intent.putExtras().getString("FILE_NAME"); has done or not.


You can store in a String variable if you send String data as below and print in cosole to check it:

Bundle b=intent.getExtras();
String str=b.getString("FILE_NAME"); //IF YOU HAVE STRING AS VALUE THEN USE getString() else use accordingly.
System.out.println(str);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜