• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps "unfortunately findingHouses has stopped"-Error

Abisheak

Lurker
Dec 21, 2013
4
0
Hello guys,
I have a problem with my app.It crashes when i click the calc price button.It worked well before i did type casting from string to int and int to string.After that whenever i click the calc price button ,it just crashes.
This is my logcat view.
4lm95vhmp

This is the app screen before it crashes
p5bu28uqj


This is the mainActivity.java:
[HIGH]package com.example.findinghouses;

import android.os.Bundle;
import android.view.View;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.widget.EditText;


public class MainActivity extends Activity {
public final static String FamilyIncome = "com.example.findinghouses.income";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
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;
}

public void calcPrice(View view){
Intent intent = new Intent(this,CalcHousePrice.class);
EditText editText1 = (EditText) findViewById(R.id.editText1);
float income = Float.parseFloat(editText1.getText().toString());
intent.putExtra(FamilyIncome, income);
startActivity(intent);

}

}
[/HIGH]

This is the intent's Activity class(CalcHousePrice.class):
[HIGH]package com.example.findinghouses;

import android.os.Bundle;
import android.content.Intent;
import android.app.Activity;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
import android.annotation.TargetApi;
import android.os.Build;
import android.widget.EditText;

public class CalcHousePrice extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Show the Up button in the action bar.
setupActionBar();
Intent intent = getIntent();
int income = Integer.parseInt(intent.getStringExtra(MainActivity.FamilyIncome));
income = income * 4 * 100;
String income1 = Integer.toString(income);
EditText editText = new EditText(this);
editText.setText(income1);
editText.setTextSize(30);
setContentView(editText);
}

/**
* Set up the {@link android.app.ActionBar}, if the API is available.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setupActionBar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
getActionBar().setDisplayHomeAsUpEnabled(true);
}
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
// This ID represents the Home or Up button. In the case of this
// activity, the Up button is shown. Use NavUtils to allow users
// to navigate up one level in the application structure. For
// more details, see the Navigation pattern on Android Design:
//
// Navigation with Back and Up | Android Developers
//
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}

}[/HIGH]

Thank you
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones