In my application, after clicking the button it should be able to call the corresponding number (which was given by the user). But the problem is when I dial, it says unfortunately the project has stopped.
Now I am running the app in emulator, and I know that without network it shouldn't work. Instead it was supposed to show an error message. But why it stopps application?
Activity 1:
public class Activity1 extends ActionBarActivity {
public static final String PREFS_TITLE = "SaveFile";
TextView phnNum;
public static final String Mob = "CallButton";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activity1);
//finting the properties by given ID
final EditText title = (EditText) findViewById(R.id.title);
final EditText name = (EditText) findViewById(R.id.name);
final EditText text = (EditText) findViewById(R.id.text);
phnNum = (TextView) findViewById(R.id.phone);
final EditText price = (EditText) findViewById(R.id.price);
//adding the button clickable functionality
Button nextViewButton = (Button) findViewById(R.id.Next_View);
nextViewButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
SharedPreferences saveValue = getSharedPreferences(PREFS_TITLE, 0);
SharedPreferences.Editor editor = saveValue.edit();
editor.putString("Title", title.getText().toString());
editor.putString("Name", name.getText().toString());
editor.putString("Text", title.getText().toString());
editor.putString("Phone", phnNum.getText().toString());
editor.putString("Price", price.getText().toString());
editor.commit();
Intent intent = new Intent((getApplicationContext()), Activity2.class);
startActivity(intent);
}
}
);
}
}
Activity 2:
public class Activity2 extends ActionBarActivity {
public static String PREFS_TITLE = "SaveFile";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_activity2);
TextView title_Avtivity2=(TextView)findViewById(R.id.title);
TextView name_Avtivity2=(TextView)findViewById(R.id.name);
TextView text_Avtivity2=(TextView)findViewById(R.id.text);
TextView phon_Avtivity2=(TextView)findViewById(R.id.phone);
TextView price_Avtivity2=(TextView)findViewById(R.id.price);
Button callingButton=(Button)findViewById(R.id.call);
SharedPreferences savedValue_Activity2=getSharedPreferences(PREFS_TITLE,0);
title_Avtivity2.setText(savedValue_Activity2.getString("Title","No input"));
name_Avtivity2.setText(savedValue_Activity2.getString("Name","No input"));
text_Avtivity2.setText(savedValue_Activity2.getString("Text","No input"));
phon_Avtivity2.setText(savedValue_Activity2.getString("Phone","No input"));
price_Avtivity2.setText(savedValue_Activity2.getString("Price","No input"));
}
public void call(View view){
SharedPreferences getphonNum=getSharedPreferences(PREFS_TITLE,0);
String warningMsg=getphonNum.getString("Phone","No phone number input");
System.out.println(warningMsg);
Intent intentForPhon=new Intent(Intent.ACTION_CALL,Uri.parse("Phon Num: "+warningMsg));
startActivity(intentForPhon);
}
}