gpt4 book ai didi

android - 自动一一列出去电

转载 作者:行者123 更新时间:2023-11-29 00:40:23 24 4
gpt4 key购买 nike

我想从我的手机调用电话号码列表(4/5 个号码);我在通话中调用电话,结束该通话后只需调用下一个号码(这是自动的)。我的想法是:

   for(int i=0;i<aray.lenght;i++)
{
callIntent=new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+num));
startActivity(callintent);
}

我们知道默认情况下只有两个去电。我想限制一个去电。在谈话/结束之后; next number will call,这个过程会一直持续到号码列表结束。这里我们还必须检查拨出电话的状态,振铃,摘机和空闲;我们如何知道或仅使用三种状态进行单次调用。尝试提供帮助。

最佳答案

这样试试让 nums 成为数字列表..

 public class CallsActivity extends Activity {

final Context context = this;
public String num;
String LOG_TAG = "EMERGENCY CALL";

public String[] pnum={"9666848344","9603939029","7404230210","9030109791"};
ArrayList<String> b= new ArrayList<String>(Arrays.asList(pnum));
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.main);
num=b.get(0);
call(num);
// add PhoneStateListener
PhoneCallListener phoneListener = new PhoneCallListener();
TelephonyManager telephonyManager = (TelephonyManager) this
.getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.listen(phoneListener,
PhoneStateListener.LISTEN_CALL_STATE);



}
void call(String num1)
{
Intent callIntent=new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+num1));
startActivity(callIntent);
int indx=b.indexOf(num1);

//Log.i(LOG_TAG, "indx"+indx);
if (indx!=b.size())
{
num=b.get(indx+1);
}

}

private class PhoneCallListener extends PhoneStateListener {

private boolean isPhoneCalling = false;


@Override
public void onCallStateChanged(int state, String incomingNumber) {

if (TelephonyManager.CALL_STATE_RINGING == state) {
// phone ringing
Log.i(LOG_TAG, "RINGING, number: " + incomingNumber);
}

if (TelephonyManager.CALL_STATE_OFFHOOK == state) {
// active
Log.i(LOG_TAG, "OFFHOOK");

isPhoneCalling = true;
}

if (TelephonyManager.CALL_STATE_IDLE == state) {
// run when class initial and phone call ended, need detect flag
// from CALL_STATE_OFFHOOK
Log.i(LOG_TAG, "IDLE");

if (isPhoneCalling) {

Log.i(LOG_TAG, "CALL...");

// restart app
Intent i = getBaseContext().getPackageManager()
.getLaunchIntentForPackage(
getBaseContext().getPackageName());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// startActivity(i);
call(num);
isPhoneCalling = false;
}

}
}
}

}

关于android - 自动一一列出去电,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9766002/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com