
android打电话出现No Activity found to handle Intent { act=android.intent.action.CALL }报错
用了android官方BLE的demo可以成功接收Arduino101板子传入的数据;在原来的程序中直接加入打电话的代码,可以实现privatevoiddisplayDa...
用了android官方BLE的demo可以成功接收Arduino101板子传入的数据;
在原来的程序中直接加入打电话的代码,可以实现
private void displayData(String data) {
if (data != null) {
mDataDisplay.setText(data);
}
button = (Button) findViewById(R.id.button);
number=data;
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:000000"));
if (ActivityCompat.checkSelfPermission(DeviceControlActivity.this,
Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
return;
}
startActivity(callIntent);
}
});
————————————————————————————————
但是如果利用接收到的数据,就出现报错No Activity found to handle Intent { act=android.intent.action.CALL }
private void displayData(String data) {
if (data != null) {
mDataDisplay.setText(data);
}
button = (Button) findViewById(R.id.button);
number=data;
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
if(number.equals("00"))
{
callIntent.setData(Uri.parse("tel:000000"));
}else if(number.equals("01"))
{
callIntent.setData(Uri.parse("tel:000001"));
}else if(number.equals("02"))
{
callIntent.setData(Uri.parse("tel:000002"));
}else if(number.equals("03"))
{
callIntent.setData(Uri.parse("tel:000003"));
}else if(number.equals("04"))
{
callIntent.setData(Uri.parse("tel:000004"));
}else if(number.equals("05"))
{
callIntent.setData(Uri.parse("tel:000005"));
}
if (ActivityCompat.checkSelfPermission(DeviceControlActivity.this,
Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
return;
}
startActivity(callIntent);
}
}); 展开
在原来的程序中直接加入打电话的代码,可以实现
private void displayData(String data) {
if (data != null) {
mDataDisplay.setText(data);
}
button = (Button) findViewById(R.id.button);
number=data;
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:000000"));
if (ActivityCompat.checkSelfPermission(DeviceControlActivity.this,
Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
return;
}
startActivity(callIntent);
}
});
————————————————————————————————
但是如果利用接收到的数据,就出现报错No Activity found to handle Intent { act=android.intent.action.CALL }
private void displayData(String data) {
if (data != null) {
mDataDisplay.setText(data);
}
button = (Button) findViewById(R.id.button);
number=data;
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
if(number.equals("00"))
{
callIntent.setData(Uri.parse("tel:000000"));
}else if(number.equals("01"))
{
callIntent.setData(Uri.parse("tel:000001"));
}else if(number.equals("02"))
{
callIntent.setData(Uri.parse("tel:000002"));
}else if(number.equals("03"))
{
callIntent.setData(Uri.parse("tel:000003"));
}else if(number.equals("04"))
{
callIntent.setData(Uri.parse("tel:000004"));
}else if(number.equals("05"))
{
callIntent.setData(Uri.parse("tel:000005"));
}
if (ActivityCompat.checkSelfPermission(DeviceControlActivity.this,
Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
return;
}
startActivity(callIntent);
}
}); 展开
1个回答
展开全部
public static void startSystemDialingActivity(Context context, String phone)
{
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phone));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询