admin管理员组

文章数量:1516870

让跳出打电话和发短信字样的窗口:然后实现打电话和发短信功能:

网友的:

public class Android3G1_01Activity extends Activity {

/** Called when the activity is first created. */

private Button bt = null ;

private EditText tv = null ;

//private String action="android.intent.action.CALL";

//private String type="tel";

@ Override

public void onCreate(Bundle savedInstanceState) {

super .onCreate(savedInstanceState);

setContentView(R.layout.main);

bt=(Button) findViewById(R.id.bt);

tv=(EditText) findViewById(R.id.edt);

bt.setOnClickListener( new OnClickListener() {

public void onClick(View v) {

// TODO Auto-generated method stub

String mobileNum=tv.getText().toString();

Intent  intent=

new Intent(Intent.ACTION_CALL,Uri.parse( "tel:" +mobileNum));

startActivity(intent);

/**

*原创的思想给了我的主要的思考方向

*但是call在我的代码中没有用,会报错,但是DIAL有用
* @author YJBo
*/

}

});

}

我的:

new AlertDialog.Builder( this ).setMessage( "欢迎使用NB软件" )

.setPositiveButton( "发短信" , new OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

// boolean callOnClick = tv_phone.callOnClick();

// dialog.notify();

// dialog = (DialogInterface) tv_phone;

// boolean click = tv_phone.callOnClick();

/*

* (non- Javadoc ) 那个“按钮事件连接到实际的打电话中还是不能的,自己想不懂应该怎么弄

*/

try {

// 我之前用的是ACTION_CALL,但是不行,得用ACTION_DIAL

Intent intent = new Intent(Intent. ACTION_SENDTO , Uri.parse( "smsto:"

+ _phone.getText().toString()));

startActivity(intent);

Toast.makeText(MainActivity. this , "点我啊.......!"

+ tv_phone.getText().toString(),

Toast. LENGTH_LONG ).show();

} catch (Exception e) {

e.printStackTrace();

}

}

}).setNegativeButton( "打电话" , new OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

try {

// 我之前用的是ACTION_CALL,但是不行,得用ACTION_DIAL

Intent intent = new Intent(Intent. ACTION_DIAL , Uri

.parse( "tel:" + tv_phone.getText().toString()));

startActivity(intent);

Toast.makeText(MainActivity. this , "点我啊.......!"

+ tv_phone.getText().toString(),

Toast. LENGTH_LONG ).show();

} catch (Exception e) {

e.printStackTrace();

}

}

}).create().show();

// 解析的时候,一定要与之对应:短信: smsto ;电话: tel

// 意图时:短信: Intent. ACTION_SENDTO ;电话: Intent. ACTION_DIAL

// 主要就是注意这俩段代码:

1 . Intent intent = new Intent(Intent. ACTION_SENDTO , Uri.parse( "smsto:"

+ _phone.getText().toString()));

startActivity(intent);

2).Intent intent = new Intent(Intent. ACTION_DIAL , Uri

.parse( "tel:" + tv_phone.getText().toString()));

startActivity(intent);

本文标签: 的是我之前用编程