I switched from running my app on a phone to a nexus 10 tablet and now it says "unfortunately the application has stopped."
The tablet is running 4.4.2, my target api is set to 19 in the manifest.
When I run it in debug mode I get Source Not Found. I tried clicking edit source lookup path and adding my project and had no luck.
I've looked all over the internet and haven't had any luck solving this problem. Any suggestions would be a big help.
"java.lang.RuntimeException: Unable to start activity ComponentInfo{com.looper.video/com.looper.video.MainActivity}: java.lang.NullPointerException"
Edit:
MainActivity:
package com.looper.video;
public class MainActivity extends Activity {
private VideoView video;
private MediaController ctlr;
final Uri firstVideoPath = Uri.parse("android.resource://com.looper.video/" + R.raw.wildlife);
final Uri secondVideoPath = Uri.parse("android.resource://com.looper.video/" + R.raw.wildlife1);
private String videosPath = Environment.getExternalStorageDirectory() + "/videos/";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
File folder = new File(videosPath);
File[] customFiles = folder.listFiles();
List<String> customFileNames = new ArrayList<String>();
for(File file : customFiles) {
customFileNames.add(file.getName());
}
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item, customFileNames);
spinnerArrayAdapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );
Spinner spinner = (Spinner)findViewById(R.id.spinnerCustomFiles);
spinner.setAdapter(spinnerArrayAdapter);
video = (VideoView)findViewById(R.id.videoView1);
ctlr = new MediaController(this);
final Button firstVideoBtn = (Button) findViewById(R.id.firstVideoBtn);
firstVideoBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
playFirstVideo();
}
});
final Button secondVideoBtn = (Button) findViewById(R.id.secondVideoBtn);
secondVideoBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
playSecondVideo();
}
});
}
public void playFeatured(View v) {
try {
Spinner spinner = (Spinner)findViewById(R.id.spinnerCustomFiles);
String strPath = videosPath + spinner.getSelectedItem().toString();
Toast.makeText(this, strPath, Toast.LENGTH_LONG).show();
//Uri path = Uri.parse(videosPath + spinner.getSelectedItem().toString());
video.setVideoPath(strPath);
ctlr.setMediaPlayer(video);
video.setMediaController(ctlr);
video.requestFocus();
video.start();
video.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
#Override
public void onCompletion(MediaPlayer vmp) {
playSecondVideo();
}
});
} catch(Exception e) {
System.out.println(e.getMessage());
}
}
public void playFirstVideo() {
video.setVideoURI(firstVideoPath);
ctlr.setMediaPlayer(video);
video.setMediaController(ctlr);
video.requestFocus();
video.start();
video.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
#Override
public void onCompletion(MediaPlayer vmp) {
playSecondVideo();
}
});
}
public void playSecondVideo() {
SharedPreferences sp = getSharedPreferences("schedule", Context.MODE_PRIVATE);
//SimpleDateFormat sdf = new SimpleDateFormat("hh:mm");
String startTime = sp.getString("startTime", "");
String endTime = sp.getString("endTime", "");
/*
//SimpleDateFormat parser = new SimpleDateFormat("HH:mm");
//Date dateStartTime = parser.parse(startTime);
//Date dateEndTime = parser.parse(endTime);
Date now = new Date();
try {
if (userDate.after(ten) && userDate.before(eighteen)) {
}
} catch (ParseException e) {
// Invalid date was entered
}
System.out.println("Now:"+now);
System.out.println("Start"+startTime);
System.out.println("End:"+endTime);
//if(now.before(dateEndTime) && now.after(dateStartTime)){
//disableAll();
//} else {
*
*/
video.setVideoURI(secondVideoPath);
ctlr.setMediaPlayer(video);
video.setMediaController(ctlr);
video.requestFocus();
video.start();
video.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
#Override
public void onCompletion(MediaPlayer vmp) {
playSecondVideo();
}
});
//}
}
public void admin(View view)
{
//MySQLiteHelper db = new MySQLiteHelper(this);
//final String password = db.getUser(7).getPassword();
//db.close();
final AlertDialog.Builder alert = new AlertDialog.Builder(this);
final EditText pass = new EditText(this);
alert.setView(pass);
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = pass.getText().toString().trim();
SharedPreferences sp1 = getSharedPreferences("Login", 0);
//String username = sp1.getString("UserName", "");
String password = sp1.getString("Password", "");
if(value.equals(password)) {
Intent intent = new Intent(getBaseContext(),Admin.class);
startActivity(intent);
}
//Toast.makeText(getApplicationContext(), password + " " + value, Toast.LENGTH_SHORT).show();
}
});
alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
}
});
alert.show();
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void disableAll(){
Button firstVideoBtn = (Button)findViewById(R.id.firstVideoBtn);
firstVideoBtn.setEnabled(false);
Button secondVideoBtn = (Button)findViewById(R.id.secondVideoBtn);
secondVideoBtn.setEnabled(false);
Spinner spinner = (Spinner)findViewById(R.id.spinnerCustomFiles);
spinner.setEnabled(false);
Button btnPlay = (Button)findViewById(R.id.btnPlayFeatured);
btnPlay.setEnabled(false);
VideoView videoView = (VideoView)findViewById(R.id.videoView1);
videoView.setEnabled(false);
}
}
Full logcat:
D/dalvikvm(2817): GC_FOR_ALLOC freed 58K, 4% free 3441K/3568K, paused 20ms, total 20ms
10-08 15:23:17.965: D/dalvikvm(2817): GC_FOR_ALLOC freed 2K, 4% free 3505K/3632K, paused 7ms, total 7ms
10-08 15:23:17.975: I/dalvikvm-heap(2817): Grow heap (frag case) to 8.739MB for 5515216-byte allocation
10-08 15:23:17.985: D/dalvikvm(2817): GC_FOR_ALLOC freed <1K, 2% free 8891K/9020K, paused 7ms, total 7ms
10-08 15:23:18.055: D/AndroidRuntime(2817): Shutting down VM
10-08 15:23:18.055: W/dalvikvm(2817): threadid=1: thread exiting with uncaught exception (group=0x4155eba8)
10-08 15:23:18.055: E/AndroidRuntime(2817): FATAL EXCEPTION: main
10-08 15:23:18.055: E/AndroidRuntime(2817): Process: com.looper.video, PID: 2817
10-08 15:23:18.055: E/AndroidRuntime(2817): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.looper.video/com.looper.video.MainActivity}: java.lang.NullPointerException
10-08 15:23:18.055: E/AndroidRuntime(2817): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
10-08 15:23:18.055: E/AndroidRuntime(2817): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
10-08 15:23:18.055: E/AndroidRuntime(2817): at android.app.ActivityThread.access$800(ActivityThread.java:135)
10-08 15:23:18.055: E/AndroidRuntime(2817): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
10-08 15:23:18.055: E/AndroidRuntime(2817): at android.os.Handler.dispatchMessage(Handler.java:102)
10-08 15:23:18.055: E/AndroidRuntime(2817): at android.os.Looper.loop(Looper.java:136)
10-08 15:23:18.055: E/AndroidRuntime(2817): at android.app.ActivityThread.main(ActivityThread.java:5017)
10-08 15:23:18.055: E/AndroidRuntime(2817): at java.lang.reflect.Method.invokeNative(Native Method)
10-08 15:23:18.055: E/AndroidRuntime(2817): at java.lang.reflect.Method.invoke(Method.java:515)
10-08 15:23:18.055: E/AndroidRuntime(2817): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
10-08 15:23:18.055: E/AndroidRuntime(2817): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
10-08 15:23:18.055: E/AndroidRuntime(2817): at dalvik.system.NativeStart.main(Native Method)
10-08 15:23:18.055: E/AndroidRuntime(2817): Caused by: java.lang.NullPointerException
10-08 15:23:18.055: E/AndroidRuntime(2817): at com.looper.video.MainActivity.onCreate(MainActivity.java:52)
10-08 15:23:18.055: E/AndroidRuntime(2817): at android.app.Activity.performCreate(Activity.java:5231)
10-08 15:23:18.055: E/AndroidRuntime(2817): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
10-08 15:23:18.055: E/AndroidRuntime(2817): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
10-08 15:23:18.055: E/AndroidRuntime(2817): ... 11 more
Related
I have been trying for a long time to work on a button onClick listener that performs the following
launch a loading screen (progress bar).
Send an sms msg in the background to a specific number.
wait for the reply using broadcast listener, which is a message containing a link.
dismiss the loading screen.
then take this link and use it to start another activity.
The code shows no errors, however each time I press the button it doesn't show the progress bar, it only sends a message then waits for the specified time then crashes.
Here's the code
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new OnClickListener(){
#Override
`public void onClick(View arg0) {
// TODO Auto-generated method stub
new LoadTracker().execute();
}});
}
protected void sendSMS() {
// TODO Auto-generated method stub
String Phoneno = "***********";
String Message = "www.google.com";
SmsManager manager= SmsManager.getDefault();
manager.sendTextMessage(Phoneno, null, Message, null, null);
}
private BroadcastReceiver Receiver = new BroadcastReceiver(){
public static final String SMS_BUNDLE = "pdus";
#Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Bundle intentExtras = intent.getExtras();
if (intentExtras != null) {
Object[] sms = (Object[]) intentExtras.get(SMS_BUNDLE);
for (int i = 0; i < sms.length; ++i) {
SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) sms[i]);
String smsBody = smsMessage.getMessageBody().toString();
Intent in = new Intent(Intent.ACTION_VIEW, Uri.parse(smsBody));
startActivity(in);
}
}
}};
private class LoadTracker extends AsyncTask<Void, Integer, Void>{
protected void onPreExecute(){
progressDialog = new ProgressDialog(MainActivity.this);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setTitle("Sending Signal");
progressDialog.setMessage("Receiving Signal, Please Wait");
progressDialog.setCancelable(false);
progressDialog.setIndeterminate(false);
progressDialog.setMax(100);
progressDialog.setProgress(0);
progressDialog.show();
}
#Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
try{
synchronized (this){
IntentFilter IF = new IntentFilter("android.provider.Telephony.SMS_RECEIVED");
sendSMS();
registerReceiver(Receiver,IF);
this.wait(10000);
this.wait(10000);
publishProgress(100);
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
protected void onProgressUpdate(Integer... values){
progressDialog.setProgress(values[0]);
}
#Override
protected void onPostExecute(Void result)
{
//close the progress dialog
progressDialog.dismiss();
//initialize the View
setContentView(R.layout.activity_main);
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
#Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(Receiver);
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Note: The Phone number belongs to the phone on which the application is running so it should open google after it receives the reply
All the uses permissions are in place too.
Update: I discovered the problem with the progress dialog, the "O" letter in OnPreExecute Should've been lower case. Now the progress Dialog appears and the app sends the message however, the app crashes as soon as the reply sms message is received. How can I solve this?
Logcat:
04-20 19:45:45.950: W/dalvikvm(15877): threadid=1: thread exiting with uncaught exception (group=0x40c4b1f8)
04-20 19:45:45.974: E/AndroidRuntime(15877): FATAL EXCEPTION: main
04-20 19:45:45.974: E/AndroidRuntime(15877): java.lang.RuntimeException: Error receiving broadcast Intent { act=android.provider.Telephony.SMS_RECEIVED flg=0x10 (has extras) } in com.example.finalprototype.MainActivity$1#4162c988
04-20 19:45:45.974: E/AndroidRuntime(15877): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:741)
04-20 19:45:45.974: E/AndroidRuntime(15877): at android.os.Handler.handleCallback(Handler.java:605)
04-20 19:45:45.974: E/AndroidRuntime(15877): at android.os.Handler.dispatchMessage(Handler.java:92)
04-20 19:45:45.974: E/AndroidRuntime(15877): at android.os.Looper.loop(Looper.java:137)
04-20 19:45:45.974: E/AndroidRuntime(15877): at android.app.ActivityThread.main(ActivityThread.java:4512)
04-20 19:45:45.974: E/AndroidRuntime(15877): at java.lang.reflect.Method.invokeNative(Native Method)
04-20 19:45:45.974: E/AndroidRuntime(15877): at java.lang.reflect.Method.invoke(Method.java:511)
04-20 19:45:45.974: E/AndroidRuntime(15877): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:982)
04-20 19:45:45.974: E/AndroidRuntime(15877): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)
04-20 19:45:45.974: E/AndroidRuntime(15877): at dalvik.system.NativeStart.main(Native Method)
04-20 19:45:45.974: E/AndroidRuntime(15877): Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=www.google.com }
04-20 19:45:45.974: E/AndroidRuntime(15877): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1535)
04-20 19:45:45.974: E/AndroidRuntime(15877): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1387)
04-20 19:45:45.974: E/AndroidRuntime(15877): at android.app.Activity.startActivityForResult(Activity.java:3190)
04-20 19:45:45.974: E/AndroidRuntime(15877): at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:817)
04-20 19:45:45.974: E/AndroidRuntime(15877): at android.app.Activity.startActivity(Activity.java:3297)
04-20 19:45:45.974: E/AndroidRuntime(15877): at com.example.finalprototype.MainActivity$1.onReceive(MainActivity.java:75)
04-20 19:45:45.974: E/AndroidRuntime(15877): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:732)
04-20 19:45:45.974: E/AndroidRuntime(15877): ... 9 more
04-20 19:45:56.013: I/Process(15877): Sending signal. PID: 15877 SIG: 9
Not sure but from the following line
ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=www.google.com ...
I think your URL should be like http://www.google.com. Its missing the protocol http without which it might not recognize the right activity to handle the Intent.
I am a newcomer for android programming and stack overflow. MY problem here is mylongitudey in onclick method is giving null value. I have 3 activities.Below one is one among them. I want the latitude and longitude from google map and to send those points into another activity. The main problem here is, it is not giving the latitude and longitude value instead Toasting null value. I couldn't find what was the mistake . Can anyone help me? Thanks in advanced.
SharedPreferences points;
SharedPreferences.Editor ed;
Address returnedAddress;
double mylongitudey,mylatitudey;
String latilongi;
ImageView iv;
Button manual,proceed;
GoogleMap map;
LatLng mylat ;
String latlong;
Marker mymarker;
boolean markerclicked;
double mylatitudeyd,mylongitudeyd;
String addstringaa;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.two_buttons);
actionBar = getActionBar();
actionBar.setBackgroundDrawable(new ColorDrawable(Color.BLACK));
getActionBar().setDisplayHomeAsUpEnabled(true);
Toast.makeText(this,"Please select the destination by long click", Toast.LENGTH_LONG).show();
LatLng mylat;
final GoogleMap map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
map.setOnMarkerDragListener(this);
map.setTrafficEnabled(true);
// map.setOnMyLocationButtonClickListener(this);
SharedPreferences shared = getSharedPreferences("map", 0);
String mylats = (shared.getString("twolati", "NoValue"));
String mylong= (shared.getString("twolong", "NoValue"));
double dmylats = Double.valueOf(mylats);
double dmylong = Double.valueOf(mylong);
map.animateCamera(CameraUpdateFactory.zoomTo(15));
mylat = new LatLng(dmylats, dmylong);
try {
Toast.makeText(this, "This is"+mylats,Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(this,"problem in mylat",0);
e.printStackTrace();
}
map.moveCamera(CameraUpdateFactory.newLatLngZoom(mylat, 13));
map.addMarker(new MarkerOptions().position(mylat).title("You are Here"));
markerclicked=false;
//onMyLocationButtonClick();
map.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() {
#Override
public void onMapLongClick(LatLng arg0) {
// TODO Auto-generated method stub
if(markerclicked==false)
{
mymarker = map.addMarker(new MarkerOptions().position(arg0).title("Your Destination").draggable(true));
markerclicked=true;
}else{
Toast.makeText(getApplicationContext(), "Marker Aready Set..!", Toast.LENGTH_LONG).show();
}
}
});
map.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
LatLng mylatlong;
#Override
public void onMyLocationChange(Location arg0) {
// TODO Auto-generated method stub
mylongitudey = arg0.getLongitude();
mylatitudey = arg0.getLatitude();
mylatlong = new LatLng(arg0.getLatitude(), arg0.getLongitude());
//sourcepoint=String.format(" ",mylat);
// map.moveCamera(CameraUpdateFactory.newLatLngZoom(mylat,1));
map.moveCamera(CameraUpdateFactory.newLatLngZoom(mylatlong, 14));
}
});
// Toast.makeText(this, getmapid, Toast.LENGTH_LONG).show();
SharedPreferences pr= getSharedPreferences("reserve", 0);
latilongi=pr.getString("sourcepoint", "sourcepoint");
manual=(Button)findViewById(R.id.manuel);
manual.setOnClickListener(this);
proceed=(Button)findViewById(R.id.proceed);
proceed.setOnClickListener(this);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.actionmenu, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Take appropriate action for each action item click
// Toast.makeText(MainActivity.this, item.getTitle(),
// Toast.LENGTH_LONG).show();
switch (item.getItemId()) {
case android.R.id.home:
if (getParentActivityIntent() == null) {
Log.i("tag", "You have forgotten to specify the parentActivityName in the AndroidManifest!");
onBackPressed();
} else {
NavUtils.navigateUpFromSameTask(this);
}
return true;
case R.id.action_refresh:
// refresh
Intent intent = new Intent(Drop_Off_Location.this, Main.class);
startActivityForResult(intent, 0);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
#Override
public void onClick(View v) {
try {
if (v.getId() == R.id.proceed) {
/* Toast.makeText(this, "address"+mylongitudey, 0);
Toast.makeText(this, " destination in DOL class "+addstringaa, 0).show();*/
points= getSharedPreferences("map", 0);
ed=points.edit();
String twolatitudey = String.valueOf(mylatitudey);
String twolongitudey = String.valueOf(mylongitudey);
ed.putString("twolatitudey",twolatitudey);
ed.putString("twolongitudey", twolongitudey);
ed.commit();
Toast.makeText(this, "dest longitude"+mylongitudey, Toast.LENGTH_LONG).show();
Intent intent = new Intent(Drop_Off_Location.this,Autofill.class);
startActivity(intent);
}
else if(v.getId()==R.id.manuel)
{
Intent intent = new Intent(Drop_Off_Location.this,Reserve.class);
startActivity(intent);
}
} catch (Exception e) {
Toast.makeText(this,"error in onclick"+e, Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
Logcat verbose:
10-08 02:23:53.965: D/dalvikvm(3221): GC_FOR_ALLOC freed 111K, 25% free 7167K/9528K, paused 132ms, total 134ms
10-08 02:23:53.975: I/dalvikvm-heap(3221): Grow heap (frag case) to 9.411MB for 2457616-byte allocation
10-08 02:23:54.145: D/dalvikvm(3221): GC_FOR_ALLOC freed 2K, 20% free 9565K/11932K, paused 167ms, total 167ms
10-08 02:23:55.895: W/System.err(3221): java.io.IOException: Service not Available
10-08 02:23:55.895: W/System.err(3221): at android.location.Geocoder.getFromLocation(Geocoder.java:136)
10-08 02:23:55.905: W/System.err(3221): at jasperit.atlcitylimo.Autofill.onCreate(Autofill.java:189)
10-08 02:23:55.905: W/System.err(3221): at android.app.Activity.performCreate(Activity.java:5231)
10-08 02:23:55.905: W/System.err(3221): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
10-08 02:23:55.905: W/System.err(3221): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
10-08 02:23:55.905: W/System.err(3221): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
10-08 02:23:55.905: W/System.err(3221): at android.app.ActivityThread.access$800(ActivityThread.java:135)
10-08 02:23:55.905: W/System.err(3221): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
10-08 02:23:55.905: W/System.err(3221): at android.os.Handler.dispatchMessage(Handler.java:102)
10-08 02:23:55.905: W/System.err(3221): at android.os.Looper.loop(Looper.java:136)
10-08 02:23:55.905: W/System.err(3221): at android.app.ActivityThread.main(ActivityThread.java:5017)
10-08 02:23:55.905: W/System.err(3221): at java.lang.reflect.Method.invokeNative(Native Method)
10-08 02:23:55.915: W/System.err(3221): at java.lang.reflect.Method.invoke(Method.java:515)
10-08 02:23:55.915: W/System.err(3221): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
10-08 02:23:55.915: W/System.err(3221): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
10-08 02:23:55.915: W/System.err(3221): at dalvik.system.NativeStart.main(Native Method)
10-08 02:23:56.015: W/System.err(3221): java.io.IOException: Service not Available
10-08 02:23:56.015: W/System.err(3221): at android.location.Geocoder.getFromLocation(Geocoder.java:136)
10-08 02:23:56.035: W/System.err(3221): at jasperit.atlcitylimo.Autofill.onCreate(Autofill.java:227)
10-08 02:23:56.035: W/System.err(3221): at android.app.Activity.performCreate(Activity.java:5231)
10-08 02:23:56.035: W/System.err(3221): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
10-08 02:23:56.045: W/System.err(3221): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
10-08 02:23:56.045: W/System.err(3221): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
10-08 02:23:56.045: W/System.err(3221): at android.app.ActivityThread.access$800(ActivityThread.java:135)
10-08 02:23:56.045: W/System.err(3221): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
10-08 02:23:56.045: W/System.err(3221): at android.os.Handler.dispatchMessage(Handler.java:102)
10-08 02:23:56.045: W/System.err(3221): at android.os.Looper.loop(Looper.java:136)
10-08 02:23:56.085: W/System.err(3221): at android.app.ActivityThread.main(ActivityThread.java:5017)
10-08 02:23:56.085: W/System.err(3221): at java.lang.reflect.Method.invokeNative(Native Method)
10-08 02:23:56.085: W/System.err(3221): at java.lang.reflect.Method.invoke(Method.java:515)
10-08 02:23:56.085: W/System.err(3221): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
10-08 02:23:56.095: W/System.err(3221): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
10-08 02:23:56.095: W/System.err(3221): at dalvik.system.NativeStart.main(Native Method)
10-08 02:23:56.255: I/Choreographer(3221): Skipped 688 frames! The application may be doing too much work on its main thread.
10-08 02:23:57.585: I/Choreographer(3221): Skipped 267 frames! The application may be doing too much work on its main thread.
10-08 02:23:58.885: I/Choreographer(3221): Skipped 114 frames! The application may be doing too much work on its main thread.
10-08 02:23:59.675: I/Choreographer(3221): Skipped 107 frames! The application may be doing too much work on its main thread.
//instance variables
private GoogleMap googleMap;
private double longitude = 0.0;
private double latitude = 0.0;
private LocationManager locationManager = null;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); // your layout
try {
initilizeMap();
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 1, this);
googleMap.setMyLocationEnabled(true);
googleMap.getUiSettings().setMyLocationButtonEnabled(true);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void initilizeMap() {
if (googleMap == null) {
googleMap = ((MapFragment) getFragmentManager().findFragmentById(
R.id.map)).getMap(); //provide your id
// check if map is created successfully or not
if (googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
#Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
longitude = location.getLongitude();
latitude = location.getLatitude();
//System.out.println(latitude+ " "+longitude );
if(!isStopFocusEnabled){
CameraPosition cameraPosition = new CameraPosition.Builder().target(
new LatLng(latitude, longitude)).zoom(12).build();
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
}
In Manifest below code must be there
<permission
android:name="com.ani.map.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.ani.map.permission.MAPS_RECEIVE" />
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- Required to show current location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Required OpenGL ES 2.0. for Maps V2 -->
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<!-- Goolge API Key -->
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="YOUR KEY" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
// Change it accordingly.... it will definitely work...
public boolean onTouchEvent(MotionEvent event)
{
int X = (int)event.getX();
int Y = (int)event.getY();
GeoPoint geoPoint = mapView.getProjection().fromPixels(X, Y);
}
When I attempt to connect to a local Database on my computer I get a list of problems.
07-31 21:29:53.036: I/System.out(1470): 1
07-31 21:29:53.046: I/System.out(1470): 2
07-31 21:29:53.106: I/System.out(1470): 3
07-31 21:29:53.326: W/EGL_emulation(1470): eglSurfaceAttrib not implemented
07-31 21:30:00.126: E/JSON(1470):{"tag":"register","success":0,"error":1,"error_msg":"Error occured in Registartion"}n
07-31 21:30:00.126: I/System.out(1470): 4
07-31 21:30:00.156: I/System.out(1470): 5
07-31 21:30:00.156: I/System.out(1470): ERROR
07-31 21:30:00.186: W/System.err(1470): java.lang.NullPointerException
07-31 21:30:00.186: W/System.err(1470): at com.example.skelotong.RegularUsercreation$ruc.doInBackground(RegularUsercreation.java:138)
07-31 21:30:00.196: W/System.err(1470): at com.example.skelotong.RegularUsercreation$ruc.doInBackground(RegularUsercreation.java:1)
07-31 21:30:00.196: W/System.err(1470): at android.os.AsyncTask$2.call(AsyncTask.java:288)
07-31 21:30:00.196: W/System.err(1470): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
07-31 21:30:00.196: W/System.err(1470): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
07-31 21:30:00.206: W/System.err(1470): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
07-31 21:30:00.206: W/System.err(1470): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
07-31 21:30:00.206: W/System.err(1470): at java.lang.Thread.run(Thread.java:841)
07-31 21:30:00.206: I/System.out(1470): 9
07-31 21:30:00.326: D/AndroidRuntime(1470): Shutting down VM
07-31 21:30:00.326: W/dalvikvm(1470): threadid=1: thread exiting with uncaught exception (group=0xb1a32ba8)
07-31 21:30:00.336: E/AndroidRuntime(1470): FATAL EXCEPTION: main
07-31 21:30:00.336: E/AndroidRuntime(1470): Process: com.example.skelotong, PID: 1470
07-31 21:30:00.336: E/AndroidRuntime(1470): java.lang.NullPointerException
07-31 21:30:00.336: E/AndroidRuntime(1470): at com.example.skelotong.RegularUsercreation$ruc.onPostExecute(RegularUsercreation.java:184)
07-31 21:30:00.336: E/AndroidRuntime(1470): at com.example.skelotong.RegularUsercreation$ruc.onPostExecute(RegularUsercreation.java:1)
07-31 21:30:00.336: E/AndroidRuntime(1470): at android.os.AsyncTask.finish(AsyncTask.java:632)
07-31 21:30:00.336: E/AndroidRuntime(1470): at android.os.AsyncTask.access$600(AsyncTask.java:177)
07-31 21:30:00.336: E/AndroidRuntime(1470): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
07-31 21:30:00.336: E/AndroidRuntime(1470): at android.os.Handler.dispatchMessage(Handler.java:102)
07-31 21:30:00.336: E/AndroidRuntime(1470): at android.os.Looper.loop(Looper.java:136)
07-31 21:30:00.336: E/AndroidRuntime(1470): at android.app.ActivityThread.main(ActivityThread.java:5017)
07-31 21:30:00.336: E/AndroidRuntime(1470): at java.lang.reflect.Method.invokeNative(Native Method)
07-31 21:30:00.336: E/AndroidRuntime(1470): at java.lang.reflect.Method.invoke(Method.java:515)
07-31 21:30:00.336: E/AndroidRuntime(1470): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
07-31 21:30:00.336: E/AndroidRuntime(1470): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
07-31 21:30:00.336: E/AndroidRuntime(1470): at dalvik.system.NativeStart.main(Native Method)
07-31 21:30:03.356: I/Process(1470): Sending signal. PID: 1470 SIG: 9
07-31 21:30:05.946: D/dalvikvm(1499): GC_FOR_ALLOC freed 179K, 12% free 3467K/3932K, paused 141ms, total 144ms
07-31 21:30:06.636: D/(1499): HostConnection::get() New Host Connection established 0xb8f39498, tid 1499
07-31 21:30:06.786: W/EGL_emulation(1499): eglSurfaceAttrib not implemented
07-31 21:30:06.796: D/OpenGLRenderer(1499): Enabling debug mode 0
Here is the code that I attempt to run.
import org.json.JSONException;
import org.json.JSONObject;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class RegularUsercreation extends ActionBarActivity implements Runnable {
Button btnRegister;
Button btnLinkToLogin;
EditText inputFullName;
EditText inputEmail;
EditText inputPassword;
TextView registerErrorMsg;
EditText inputUsername;
EditText dateofbirth;
EditText zip;
// EditText skils;
// JSON Response node names
private static String KEY_SUCCESS = "success";
// private static String KEY_ERROR = "error";
// private static String KEY_ERROR_MSG = "error_msg";
private static String KEY_UID = "uid";
private static String KEY_NAME = "name";
private static String KEY_EMAIL = "email";
private static String KEY_CREATED_AT = "created_at";
private Handler mHandler = new Handler(Looper.getMainLooper());
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_regular_usercreation);
}
public void clicker(View view) {
new ruc().execute((String[]) null);
}
public void ss(View view) {
Intent i = new Intent(getApplicationContext(), RegisterClass.class);
startActivity(i);
// Close Registration View
finish();
}
private class ruc extends AsyncTask<String, Integer, Boolean> {
final ProgressDialog pd = new ProgressDialog(RegularUsercreation.this);
#Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
pd.setMessage("Please wait");
pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);
pd.setCanceledOnTouchOutside(false);
pd.setCancelable(false);
pd.setIndeterminate(true);
pd.show();
System.out.println("1");
}
#Override
protected Boolean doInBackground(String... params) {
System.out.println(2);
// Importing all assets like buttons, text fields
inputFullName = (EditText) findViewById(R.id.FullName2);
inputEmail = (EditText) findViewById(R.id.Email2);
inputPassword = (EditText) findViewById(R.id.Password2);
inputUsername = (EditText) findViewById(R.id.Username2);
dateofbirth = (EditText) findViewById(R.id.DOB2);
zip = (EditText) findViewById(R.id.ZipCode2);
btnRegister = (Button) findViewById(R.id.create2);
btnLinkToLogin = (Button) findViewById(R.id.cancel2);
registerErrorMsg = (TextView) findViewById(R.id.errormessage3);
// skils = (EditText) findViewById(R.id.skills1);
System.out.println("3");
// Register Button Click event
String name = inputFullName.getText().toString();
String email = inputEmail.getText().toString();
String password = inputPassword.getText().toString();
String usernmae = inputUsername.getText().toString();
String birth = dateofbirth.getText().toString();
String zipcode = zip.getText().toString();
// String skills = skils.getText().toString();
UserFunction userFunction = new UserFunction();
JSONObject json = userFunction.registerUser(name, email, password,
usernmae, birth, zipcode);
System.out.println(4);
// check for login response
// check for login response
try {
if (json.getString(KEY_SUCCESS) != null) {
String res = json.getString(KEY_SUCCESS);
System.out.println("5");
if (Integer.parseInt(res) == 1) {
publishProgress(1);
// user successfully registred
// Store user details in SQLite Database
DatabaseHandler db = new DatabaseHandler(
getApplicationContext());
JSONObject json_user = json.getJSONObject("user");
System.out.println(6);
// Clear all previous data in database
userFunction.logoutUser(getApplicationContext());
db.addUser(json_user.getString(KEY_NAME),
json_user.getString(KEY_EMAIL),
json.getString(KEY_UID),
json_user.getString(KEY_CREATED_AT));
System.out.println("7");
return true;
} else {
System.out.println("ERROR");
// Error in registration
//registerErrorMsg
// .setText("Error occured in registration");
return false;
}
}
} catch (JSONException e) {
publishProgress(1);
e.printStackTrace();
System.out.println("9");
return false;
}
return true;
}
#Override
protected void onProgressUpdate(Integer... values) {
// TODO Auto-generated method stub
super.onProgressUpdate(values);
if (values.equals(1)) {
pd.setMessage("Almost Done");
}
}
#Override
protected void onPostExecute(Boolean result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
if (result == true) {
// launch dashboard
Intent dashboard = new Intent(getApplicationContext(),
HomePage.class);
// Close all views before launching Dashboard
dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(dashboard);
// Close Registration Screen
finish();
}
if (result == false) {
registerErrorMsg.setText("Error occured in registration");
}
}
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.regular_usercreation, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
#Override
public void run() {
// TODO Auto-generated method stub
mHandler.post(new Runnable() {
public void run() {
new ruc();
ruc.execute(RegularUsercreation.this);
}
});
}
}
How can this problem be fixed and what can be done in the future to prevent this?
Also why does this happen.
from the looks of is either res is null or something's null within these lines
if (Integer.parseInt(res) == 1) {
publishProgress(1);
// user successfully registred
// Store user details in SQLite Database
DatabaseHandler db = new DatabaseHandler(
getApplicationContext());
JSONObject json_user = json.getJSONObject("user");
However its hard to be sure. publishProgress or getApplicationContext may have something throwing the NullPointerException as well. Try this for debugging the problem : since you're using eclipse, you can use debugger instead of println, its way more powerful. A useful tutorial. If you don't want to use the debugger, print the values instead of numbers. They'll provide much more useeful context.
android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy#406a6678 is not valid; is your activity running?
at android.view.ViewRoot.setView(ViewRoot.java:528)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
at android.view.Window$LocalWindowManager.addView(Window.java:424)
at android.app.Dialog.show(Dialog.java:241)
at android.app.Activity.showDialog(Activity.java:2569)
at android.app.Activity.showDialog(Activity.java:2527)
at MyCode$8$4.run(MyCode.java:557)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
at dalvik.system.NativeStart.main(Native Method)
I am getting above exception when following code is executed. This file dialog will shown once the processing is done and progressbar reaches 100%. FileSaveDialog extends Dialog and implements OnCompletionListener
runOnUiThread(new Runnable() {
#Override
public void run() {
showDialog(error.Code());//Line 557
}
});
#Override
protected Dialog onCreateDialog(int id) {
Dialog dialog;
AlertDialog.Builder builder;
final ScrollView scrollView = new ScrollView(this);
final TextView textView = new TextView(this);
switch (id) {
// Other cases are here
case 4:
File playFile = new File(mediaPath, TEMP_WAV_FILE_NAME);
dialog = new FileSaveDialog(this, getResources(),
playFile.getAbsolutePath(), saveDiscardHandler);
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
#Override
public void onCancel(DialogInterface dialog) {
// do whatever you want the back key to do
cleanUp();
}
});
break;
// Other cases are here
default:
dialog = null;
}
return dialog;
}
You must check activity isFinishing() If the activity is finishing, returns true; else returns false.
I'm trying to create a ListView with 2 TextViews and 1 Button. When the users click in the button the activity will finish(); and pass the result to another view. I followed this tutorial . But for some reason when i click to start that activity my application crashes! Here is the 3 files from my app that are relevant.
List Structure Data:
public class formulasListData {
private String formulasName;
private String formulasDefinition;
public formulasListData(String formulasName, String formulasDefinition) {
super();
this.formulasName = formulasName;
this.formulasDefinition = formulasDefinition;
}
public String getFormulasName() {
return formulasName;
}
public void setFormulasName(String formulasName) {
this.formulasName = formulasName;
}
public String getFormulasDefinition() {
return formulasDefinition;
}
public void setFormulasDefinition(String formulasDefinition) {
this.formulasDefinition = formulasDefinition;
}
}
The List Adapter:
public class formulasListAdapter extends BaseAdapter implements OnClickListener {
private Context context;
private List<formulasListData> formulasList;
public formulasListAdapter(Context context, List<formulasListData> formulasList) {
this.context = context;
this.formulasList = formulasList;
}
#Override
public int getCount() {
return formulasList.size();
}
#Override
public Object getItem(int position) {
return formulasList.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View rowView, ViewGroup parent) {
formulasListData entry = formulasList.get(position);
if(rowView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
rowView = inflater.inflate(R.layout.formulas_row, null);
}
TextView formulasName = (TextView) rowView.findViewById(R.id.formulas_name);
formulasName.setText(entry.getFormulasName());
TextView formulasDefinition = (TextView) rowView.findViewById(R.id.formulas_definition);
formulasDefinition.setText(entry.getFormulasDefinition());
Button btnSelect = (Button) rowView.findViewById(R.id.selectFormula);
btnSelect.setFocusableInTouchMode(false);
btnSelect.setFocusable(false);
btnSelect.setOnClickListener(this);
btnSelect.setTag(entry);
return rowView;
}
#Override
public void onClick(View view) {
formulasListData entry = (formulasListData) view.getTag();
}
}
And the activity that should display the list.
public class FormulasList extends Activity {
private static final int FORMULA_0 = 0;
private static final int FORMULA_1 = 1;
private static final int FORMULA_2 = 2;
private static final int FORMULA_3 = 3;
private static final int FORMULA_4 = 4;
private static final int FORMULA_5 = 5;
private static final int FORMULA_6 = 6;
// private static final int FORMULA_7 = 7;
public void onCreate(Bundle savedInstance) {
super.onCreate(savedInstance);
ListView formulasListView = (ListView) findViewById(R.id.formulas_list);
formulasListView.setClickable(true);
final List<formulasListData> formulasList = new ArrayList<formulasListData>();
final String[] formulasName = new String[] {"Circunference of a Circle:",
"Area of a Circle:",
"Volume of a Sphere:",
"Area Triangle:",
"Area Square:",
"Volume of a Cube:",
"Pithagorean Theorem:"};
final String[] formulasDefinition = new String[] {"2 × π × r",
"π × r²",
"(4/3) × π × r³",
"(b × h)/2",
"side²",
"side³",
"a² + b² = c²"};
// formulasList.add(new formulasListData(formulasName, formulasDefinition));
formulasList.add(new formulasListData(formulasName[0], formulasDefinition[0]));
formulasList.add(new formulasListData(formulasName[1], formulasDefinition[1]));
formulasList.add(new formulasListData(formulasName[2], formulasDefinition[2]));
formulasList.add(new formulasListData(formulasName[3], formulasDefinition[3]));
formulasList.add(new formulasListData(formulasName[4], formulasDefinition[4]));
formulasList.add(new formulasListData(formulasName[5], formulasDefinition[5]));
formulasList.add(new formulasListData(formulasName[6], formulasDefinition[6]));
SharedPreferences settings = getSharedPreferences(SettingsActivity.PREF_NAME, MODE_PRIVATE);
SettingsActivity.newTheme = settings.getInt("themeCustom", 0);
if(SettingsActivity.newTheme == SettingsActivity.THEME_DARK) {
setTheme(R.style.DarkTheme);
} else if(SettingsActivity.newTheme == SettingsActivity.THEME_LIGHT){
setTheme(R.style.LightTheme);
} else if(SettingsActivity.newTheme == SettingsActivity.THEME_COLORS) {
setTheme(R.style.ColorsTheme);
} else {
setTheme(R.style.AppTheme);
}
setContentView(R.layout.activity_formulas);
formulasListAdapter adapter = new formulasListAdapter(this, formulasList);
formulasListView.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> arg0, View view, int position,long index) {
Intent intent= getIntent();
Bundle b = new Bundle();
switch (position) {
case FORMULA_0:
b.putString("key0", formulasDefinition[0]);
intent.putExtras(b);
setResult(RESULT_OK, intent);
finish();
break;
case FORMULA_1:
b.putString("key0", formulasDefinition[1]);
intent.putExtras(b);
setResult(RESULT_OK, intent);
finish();
break;
case FORMULA_2:
b.putString("key0", formulasDefinition[2]);
intent.putExtras(b);
setResult(RESULT_OK, intent);
finish();
break;
case FORMULA_3:
b.putString("key0", formulasDefinition[3]);
intent.putExtras(b);
setResult(RESULT_OK, intent);
finish();
break;
case FORMULA_4:
b.putString("key0", formulasDefinition[4]);
intent.putExtras(b);
setResult(RESULT_OK, intent);
finish();
break;
case FORMULA_5:
b.putString("key0", formulasDefinition[5]);
intent.putExtras(b);
setResult(RESULT_OK, intent);
finish();
break;
case FORMULA_6:
b.putString("key0", formulasDefinition[6]);
intent.putExtras(b);
setResult(RESULT_OK, intent);
finish();
break;
default:
break;
}
}
});
formulasListView.setAdapter(adapter);
}
}
Thank you very much!!
EDIT: Here is the LogCat
05-01 20:06:54.436: D/libEGL(4820): loaded /system/lib/egl/libEGL_tegra.so
05-01 20:06:54.456: D/libEGL(4820): loaded /system/lib/egl/libGLESv1_CM_tegra.so
05-01 20:06:54.466: D/libEGL(4820): loaded /system/lib/egl/libGLESv2_tegra.so
05-01 20:06:54.486: D/OpenGLRenderer(4820): Enabling debug mode 0
05-01 20:06:54.536: D/dalvikvm(4820): GC_CONCURRENT freed 170K, 4% free 7509K/7808K, paused 4ms+10ms, total 38ms
05-01 20:06:59.976: D/AndroidRuntime(4820): Shutting down VM
05-01 20:06:59.976: W/dalvikvm(4820): threadid=1: thread exiting with uncaught exception (group=0x40cde930)
05-01 20:06:59.976: E/AndroidRuntime(4820): FATAL EXCEPTION: main
05-01 20:06:59.976: E/AndroidRuntime(4820): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gabilheri.marcuscalculatorv2/com.gabilheri.marcuscalculatorv2.FormulasList}: java.lang.NullPointerException
05-01 20:06:59.976: E/AndroidRuntime(4820): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
05-01 20:06:59.976: E/AndroidRuntime(4820): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-01 20:06:59.976: E/AndroidRuntime(4820): at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-01 20:06:59.976: E/AndroidRuntime(4820): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-01 20:06:59.976: E/AndroidRuntime(4820): at android.os.Handler.dispatchMessage(Handler.java:99)
05-01 20:06:59.976: E/AndroidRuntime(4820): at android.os.Looper.loop(Looper.java:137)
05-01 20:06:59.976: E/AndroidRuntime(4820): at android.app.ActivityThread.main(ActivityThread.java:5041)
05-01 20:06:59.976: E/AndroidRuntime(4820): at java.lang.reflect.Method.invokeNative(Native Method)
05-01 20:06:59.976: E/AndroidRuntime(4820): at java.lang.reflect.Method.invoke(Method.java:511)
05-01 20:06:59.976: E/AndroidRuntime(4820): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-01 20:06:59.976: E/AndroidRuntime(4820): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-01 20:06:59.976: E/AndroidRuntime(4820): at dalvik.system.NativeStart.main(Native Method)
05-01 20:06:59.976: E/AndroidRuntime(4820): Caused by: java.lang.NullPointerException
05-01 20:06:59.976: E/AndroidRuntime(4820): at com.gabilheri.marcuscalculatorv2.FormulasList.onCreate(FormulasList.java:30)
05-01 20:06:59.976: E/AndroidRuntime(4820): at android.app.Activity.performCreate(Activity.java:5104)
05-01 20:06:59.976: E/AndroidRuntime(4820): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
05-01 20:06:59.976: E/AndroidRuntime(4820): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
05-01 20:06:59.976: E/AndroidRuntime(4820): ... 11 more
Try moving
setContentView(R.layout.activity_formulas);
To the start of the method. Right after the super call.
You are trying to use gui controls before initializing the activity layout