I am unable to start the Call activity. I get the following error:
android.content.ActivityNotFoundException: No Activity found to handle Intent
This is my code:
Intent iCall =new Intent(android.content.Intent.ACTION_CALL);
iCall.setData(Uri.parse(phoneNum));
startActivityForResult(iCall, Codes.Prefs.CALL_CODE);
The funny thing is that this should always work, because the android phone can always make a phone call, regardless of whether an app is installed or not, because making phone calls is built-in. Right?
Thanks!
Please use only one line of code :
startActivity(new Intent(Intent.ACTION_CALL,Uri.parse("tel:18004581552")));
with the permission in manifest file
android.permission.CALL_PHONE
In the manifest file for your application, make sure you have the permission:
<uses-permission android:name="android.permission.CALL_PHONE">
Also, your Intent should look more like this:
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:123456789"));
startActivity(callIntent);
did you give the permission in Android manifest file
<uses-permission android:name="android.permission.CALL_PHONE" />
Related
I went through couple of similar posts but non of them resolved my issue.
I want to call another application (service) from mine. My intent is called like this:
Intent intent = new Intent();
intent.setAction("com.something.MY_ACTION");
intent.setComponent(new ComponentName("com.some.package", "com.some.package.service.TargetService"));
startForegroundService(intent);
I have even checked manifest of the target service and package name and service name are matching
<service android:name="com.some.package.service.TargetService"
android:exported="true"
android:process=":procesName">
<intent-filter>
<action android:name="com.something.MY_ACTION" />
</intent-filter>
</service>
I have tried startForegrongService and starService methods but nothing works. I am getting folowing in logcat:
Unable to start service Intent { act=com.something.MY_ACTION cmp=com.some.package/.service.TargetService (has extras) } U=0: not found
I even tried to send the intent from Tasker and works fine but from java it does not work. The difference is that in Tasker I don't need to define component name and package of destination service. Java does not allow that and tells that intent needs to be explicit.
Any idea what is wrong?
Is there an option in java to send it without component and package name?
Thanks,
Lukas
I have an app that, due to lack of mobile data in all areas, uses phone connection to make a phone call. There is some important information on the screen in my app, so I want to place the call without leaving my app screen. Is there any way to do this?
Add the following permission in mainfest file
<uses-permission android:name="android.permission.CALL_PHONE" />
Use the below code to start calling
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + "123456789" ));
startActivity(intent);
If you want to implement inside tha app read the tutorial which will help you alot
I am developing native android app using Eclipse, I add the following permission on Android Manifest
<uses-permission android:name="android.permission.CALL_PHONE" />
Then, I get the following message when I am trying to install the android app on my device:
Directly call phone numbers this may cost you money
could I do something to hide this message because I think this is not friendly for users? maybe i need to use another permission, which is the closer one with no permission is required?
I used the following code on my adapter:
public void onClick(View v) {
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse(PhoneCall));
v.getContext().startActivity(callIntent); }
});
You are welcome to remove the CALL_PHONE permission. Then the message will not appear when the app is installed. All permissions trigger installation warnings, not just CALL_PHONE.
Note that your app only needs the CALL_PHONE permission if you use stuff like the ACTION_CALL Intent. ACTION_DIAL can also be used to place phone calls, but since it allows the user to be involved, no permission is required.
EDIT
Use this format to specify the number and user will have only to click green button "Call".
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:0123456789"));
startActivity(intent);
I am trying to write a service that runs on phone boot, and must read data off the SD card. At first I was using a reciever for android.intent.action.BOOT_COMPLETED but switched to the intent below to make sure that the SD card has been loaded.
My Issue is that on a my Nexus 7, it doesn't appear to receive the MEDIA_MOUNTED intent. The Nexus 7 doesn't have an SD card (but it has separate SD card partition). I also tried the BOOT_COMPLETED intent, with the same luck. I have tested the same code on the emulator and my Thunderbolt, and both intents work.
Manifiest:
<receiver
android:name=".StartupReceiver"
android:enabled="true"
android:exported="true"
android:label="Start the NFS Automounter Service">
<intent-filter>
<action android:name="android.intent.action.MEDIA_MOUNTED"></action>
<data android:scheme="file"/>
<!-- <action android:name="android.intent.action.BOOT_COMPLETED"></action>-->
</intent-filter>
</receiver>
The BroadcastReceiver class:
public class StartupReceiver extends BroadcastReceiver
{
#Override
public void onReceive(Context context, Intent intent)
{
//if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction()))
//if ("android.intent.action.MEDIA_MOUNTED".equals(intent.getAction()))
//{
Log.d("NFS_Automounter", "Recieved Mount");
Intent serviceIntent = new Intent("com.ancantus.nfsautomounter.AutomountService");
context.startService(serviceIntent);
//}
}
}
I commented out the intent matching just to try and log if the class is executed at all.
My only hunch is that the Nexus 7 doesn't broadcast a MEDIA_MOUNTED because it doesn't have a real SD card; but I can't receive the BOOT_COMPLETED intent either.
And to forstall the question; yes I do have the BOOT_COMPLETED permission.
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
How many times must I type in this answer before it starts coming up in enough search results that people will find it? Maybe boldface caps will work:
STARTING WITH ANDROID 3.1, NO BroadcastReceiver WILL WORK, AT ALL, UNTIL SOMETHING HAS MANUALLY RUN ONE OF THE APPLICATION'S OTHER COMPONENTS, SUCH AS A USER RUNNING AN ACTIVITY.
This is in the documentation (albeit not well located), in blog posts, and in many StackOverflow answers, such as:
https://stackoverflow.com/a/9084771/115145
https://stackoverflow.com/a/11865858/115145
https://stackoverflow.com/a/11744499/115145
So, add an activity to your app. You need some activities anyway, for settings to control your background operation, for your documentation, for your license agreement, for your privacy policy, etc.
(note: I'm not really yelling at you -- I am just frustrated that this keeps coming up despite efforts to get the word out...)
Please note that many Android devices emulate SD card in the way it does not affect access to the SD card even when desktop accesses it. Therefore it may be that Nexus 7 simply exposes all memory that way, so as it does not really mount anything, it'd not broadcast MEDIA_MOUNTED. If you want to do some tasks on boot, listening to BOOT_COMPLETED is the only correct approach.
I'm trying to redirect outgoing calls to a different phone number on an Android device. So, I use a BroadcastReceiver "listening" for the NEW_OUTGOING_CALL intent, on his onReceive() method I use the setResultData() method to change the phone number.
Like this:
public void onReceive(Context arg0, Intent arg1) {
setResultData("351978923221");
}
In the emulator all goes well, but on my real device (a crappy ZTE X850 with Android 2.1 I believe) it doesn't if the calling Intent originates in an Activity which is part of the same application. After the dialing screen appears, the phone terminates the call.
Any thoughts out there on why this happens?
Note: I know my question is basically the same as this one but I chose to ask it again anyway to provide additional details about what goes wrong.
Manifest File
An excerpt...
<receiver android:name=".OutgoingCallDetection" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL"
android:priority="9999" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
I cut the dialed call and redialed the new call. It worked perfectly on the device.
This is the code part:
setResultData(null);
Uri uri = Uri.fromParts("tel", "!Number to be dialed!", null);
Intent newIntent = new Intent(Intent.ACTION_CALL, uri);
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(newIntent);
Hope this helps.