Friday, March 28, 2014

Android Virtual Device occurrence


I created a project, everything else right, but not at the button will appear this:

Sorry!
the application phone dialer
(Process com.example.mobile) has stopped
unexpectedly.please try again
Force colse

Since the transfer is not on the picture, I'll be prompted if marked, with the brothers there ah! How to do this
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Forget to write the code, which is MainActivity.java code:
package com.example.mobile;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends Activity
{

protected void onCreate (Bundle savedInstanceState)
{
super.onCreate (savedInstanceState);
setContentView (R.layout.layout);
Button button = (Button) this.findViewById (R.id.button) ;/ / find the button's ID
button.setOnClickListener (new ButtonClickListener ()) ;/ / add listener for the button

}
private final class ButtonClickListener implements OnClickListener
{
public void onClick (View v)
{
/ / Method
EditText MobileText = (EditText) findViewById (R.id.mobile);
String number;
number = MobileText.getText () toString ();.
Intent intent = new Intent ();
intent.setAction ("android.intent.action.CALL");
/ / Intent.addCategory ("android.intent.category.DEFAULT");
intent.setData (Uri.parse ("tel:" + number));
startActivity (intent);
}
}

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;
}

}
Reply:
Manifest in adding this permission:
  

No comments:

Post a Comment