「java创建拨号」创建拨号连接
今天给各位分享java创建拨号的知识,其中也会对创建拨号连接进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
- 1、android开发怎么拨打电话
- 2、用java编写一个电话计费卡程序
- 3、使用java时候自动拨号 0936010010 是什么意思
- 4、有没有大神会写在linux下的用java实现宽带的拨号程序
- 5、大神用java写宽带拨号 怎么写啊 能不能教下我
android开发怎么拨打电话
无权限版(弹出拨号界面并自动输入电话号码,用户选择是否拨号):
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
public void Call(String Num,Context c){
if(Num !=null Num.length() 0){
Intent itt=new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+Num));
itt.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
c.startActivity(itt);
}
}
权限版(弹出拨号界面,自动输入电话号码并立刻拨号,在部分系统中会触发安全警告):
!--- 权限 ---
uses-permission android:name="android.permission.CALL_PHONE" /
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
public void Call(String Num,Context c){
if(Num !=null Num.length() 0){
Intent itt=new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+Num));
itt.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
c.startActivity(itt);
}
}
用java编写一个电话计费卡程序
import java.util.Scanner;
public class PhoneCard {
private final int id; // 卡号
private final int password; //密码
private double cash; //剩余金额
private double cashPerMin = 0.2;// 每分钟收费
private Scanner sc = new Scanner(System.in);
public PhoneCard(int id,int password,double cash) {
this.id = id;
this.password = password;
this.cash = cash;
}
/**
* 拨号计费
* @param time 拨号时间 单位分钟
* 返回剩余金额
*/
public double callSomeone(double time) {
System.out.println("请输入卡号和密码,用空格隔开");
int id = sc.nextInt();
int pw = sc.nextInt();
if(this.id == id this.password == pw) {
this.cash = this.cash - (double)time * cashPerMin;
return cash;
} else {
System.out.println("密码错误");
return -1;
}
}
}
public class TestPhoneCard {
public static void main(String[] args) {
PhoneCard pc = new PhoneCard(1, 1, 100); //初始化,卡号,密码,余额
double money = pc.callSomeone(10); //拨打10分钟
System.out.println("余额为" + money + "元");
money = pc.callSomeone(90); //继续拨打
System.out.println("余额为" + money + "元");
}
}
不知道为什么没人做
使用java时候自动拨号 0936010010 是什么意思
你在JAVA设置那里设置成你所用的(比如:中国移动 中国联通)网络 就好了 我的刚买回来的时候也是这样的
有没有大神会写在linux下的用java实现宽带的拨号程序
package cn.adsl;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class ConnectNetWork {
/**
* 执行CMD命令,并返回String字符串
*
* @param strCmd
* @return
* @throws Exception
*/
public static String exeCmd(String strCmd) throws Exception {
Process p = Runtime.getRuntime().exec("cmd /c " + strCmd);
StringBuilder sbCmd = new StringBuilder();
BufferedReader br = new BufferedReader(new InputStreamReader(p
.getInputStream()));
String line = null;
while ((line = br.readLine()) != null) {
sbCmd.append(line + "\n");
}
return sbCmd.toString();
}
/**
* 切断ADSL
*
* @param adslTitle
* @return
* @throws Exception
*/
public static boolean cutAdsl(String adslTitle) throws Exception {
// 加上"" 防止空格
String cutAdsl = "rasdial \"" + adslTitle + "\" /disconnect";
String result = exeCmd(cutAdsl);
if (result.indexOf("没有连接") != -1) {
System.err.println(adslTitle + "连接不存在!");
return false;
} else {
System.out.println("连接已断开");
return true;
}
}
/**
* 连接ADSL
*
* @param adslTitle
* @param adslName
* @param adslPass
* @param adslPhone
* @return
* @throws Exception
*/
public static boolean connAdsl(String adslTitle, String adslName,
String adslPass, String adslPhone) throws Exception {
// 加上"" 防止空格
String adslCmd = "rasdial \"" + adslTitle + "\" " + adslName + " "
+ adslPass + " /phone:" + adslPhone;
String tempCmd = exeCmd(adslCmd);
if (tempCmd.indexOf("已连接") 0) {
System.out.println("已成功建立连接.");
return true;
} else {
System.err.println(tempCmd);
System.err.println("建立连接失败");
return false;
}
}
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// rasdial "宽带名" /disconnect
String adsl = "宽带名";
String username = "username";
String password = "password";
String phone = "#12345678";
cutAdsl(adsl);
Thread.sleep(4000);
// rasdial "宽带名" 用户名 密码 /phone:#123456789
connAdsl(adsl, username, password, phone);
}
}
大神用java写宽带拨号 怎么写啊 能不能教下我
package cn.adsl;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class ConnectNetWork {
/**
* 执行CMD命令,并返回String字符串
*
* @param strCmd
* @return
* @throws Exception
*/
public static String exeCmd(String strCmd) throws Exception {
Process p = Runtime.getRuntime().exec("cmd /c " + strCmd);
StringBuilder sbCmd = new StringBuilder();
BufferedReader br = new BufferedReader(new InputStreamReader(p
.getInputStream()));
String line = null;
while ((line = br.readLine()) != null) {
sbCmd.append(line + "\n");
}
return sbCmd.toString();
}
/**
* 切断ADSL
*
* @param adslTitle
* @return
* @throws Exception
*/
public static boolean cutAdsl(String adslTitle) throws Exception {
// 加上"" 防止空格
String cutAdsl = "rasdial \"" + adslTitle + "\" /disconnect";
String result = exeCmd(cutAdsl);
if (result.indexOf("没有连接") != -1) {
System.err.println(adslTitle + "连接不存在!");
return false;
} else {
System.out.println("连接已断开");
return true;
}
}
/**
* 连接ADSL
*
* @param adslTitle
* @param adslName
* @param adslPass
* @param adslPhone
* @return
* @throws Exception
*/
public static boolean connAdsl(String adslTitle, String adslName,
String adslPass, String adslPhone) throws Exception {
// 加上"" 防止空格
String adslCmd = "rasdial \"" + adslTitle + "\" " + adslName + " "
+ adslPass + " /phone:" + adslPhone;
String tempCmd = exeCmd(adslCmd);
if (tempCmd.indexOf("已连接") 0) {
System.out.println("已成功建立连接.");
return true;
} else {
System.err.println(tempCmd);
System.err.println("建立连接失败");
return false;
}
}
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// rasdial "宽带名" /disconnect
String adsl = "宽带名";
String username = "username";
String password = "password";
String phone = "#12345678";
cutAdsl(adsl);
Thread.sleep(4000);
// rasdial "宽带名" 用户名 密码 /phone:#123456789
connAdsl(adsl, username, password, phone);
}
}
关于java创建拨号和创建拨号连接的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。