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);
版权声明:本文标题:Android004秘籍:如何在网页上集成拨打电话和发送短信功能? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.betaflare.com/web/1772193455a3272093.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论