I am trying to create a list for an android app. The app has a lot of information that I have to send. I created a csv which is then parsed like the following:
RunParallel
The issue I have is when I try to create the list from that array I have had several errors. It's too big for a bundle in Intent so I can't do it that way so I try to access the global variable like this:
public String[] getArray() {
String[] array = new String[12497];
try {
AssetInputStream asset_stream = (AssetInputStream)getAssets().open("information.csv");
BufferedReader br = new BufferedReader(new InputStreamReader(asset_stream));
line = br.readLine();
int count = 0;
while(line != null) {
fields = line.split(",");
array[count] = fields[1];
line = br.readLine();
count++;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return array;
}
As a result I keep getting an Unable to instantiate activity componentinfo error: java.lang.nullpointerexception. Also, because of the coding, I cannot initialize the array inside of the onCreate. It has to be done before. What am I doing wrong and how can I make this work? The array has to be a part of the app. Thanks.
答案 0 :(得分:0)
Why would you need it to be done before onCreate? That is the start of the Activity Lifecycle.
If you want it to be done before that, you need to find a place available before that.
Perhaps extend the $(function() {
var iframe = $('#player1')[0];
var player = $f(iframe);
var status = $('.status');
// When the player is ready, add listeners for pause, finish, and playProgress
player.addEvent('ready', function() {
status.text('ready');
player.addEvent('pause', onPause);
player.addEvent('finish', onFinish);
player.addEvent('playProgress', onPlayProgress);
});
// Call the API when a button is pressed
$('button').bind('click', function() {
player.api($(this).text().toLowerCase());
});
Class and retrieve it from there?
What is null in this case?