Reputation: 171
I made an android app to call to a number when a message is received using broadcast receiver. But I am getting an error no activity found to handle the intent. How can I solve this problem?
Code is given below
Intent intent1 = new Intent(Intent.ACTION_CALL);
intent1.setData(Uri.parse(incno1));
context.startActivity(intent1);
I added the line intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
, but this also does not solve my problem.
Upvotes: 1
Views: 127
Reputation: 464
try {
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:+123456"));
startActivity(intent);
} catch (Exception e) {
Log.e("SampleApp", "Failed to invoke call", e);
}
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
use permission in AndroidManifest.xml
Upvotes: 0
Reputation: 521
You can add it in your xml file
android:autoLink="phone"
android:phoneNumber="true"
add this to your text view that links directly to call.
Upvotes: 0
Reputation: 4082
Try this code may be working i am not tested:
Intent intent1 = new Intent(Intent.ACTION_CALL);
intent1.setData(Uri.parse("tel:" + incno1));
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent1.addFlags(Intent.FLAG_FROM_BACKGROUND);
context.startActivity(intent1);
Upvotes: 0
Reputation: 1873
The protocol is incorrect. You need to do the following:
callIntent.setData(Uri.parse("tel:"+incno1));
And ensure the following permission is set:
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
Upvotes: 1