phone link not working in the android APP - android

hello i have this link in my website <a href='tel: 123456789'>1234</a> and i am converting the website into android APP everything works fine but this tel link gives me webpage not available how can i make this to call the phone instead of treating this as a link in android app.
i have already added
<uses-permission android:name="android.permission.CALL_PHONE" />
i dont know how to fix this link issue should i use any javascript or something ??

With what I understand, you want to call the number when someone clicks it, you can use this code:
String uri = "tel:" + "NUMBER-GOES-HERE" ;
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(uri));
startActivity(intent);
Don't forget to add permission before the <application /> tag:
<uses-permission android:name="android.permission.CALL_PHONE" />

Related

Unable to create a shortcut for calling a number on Android N

This is an example of a code for creating a direct shortcut that calls a specific number and which works on Android M and below.
public void installShortcutGetId(){
Intent intent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME,"MyCallShortcut");
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, new Intent(Intent.ACTION_CALL, Uri.parse("tel:77777777")));
intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, android.R.drawable.sym_def_app_icon));
context.sendBroadcast(intent);
}
The same code doesn't work anymore on Android N, I can see in the logcat the following:
/com.android.launcher3 E/InstallShortcutReceiver: Ignoring malicious intent tel:77777777#Intent;action=android.intent.action.CALL;end
If I change ACTION_CALL to ACTION_DIAL, it works on Android N but that's not what I am looking for. I am looking for a way to make a direct call through the shortcut.
In terms of permissions, I have these 2 included and CALL_PHONE requested at run-time.
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
<uses-permission android:name="android.permission.CALL_PHONE" />
Just because your app has the CALL_PHONE permission doesn't mean the launcher has that permission: that's why your shortcut cannot be created.
You could instead create a shortcut to an empty activity of your own and start the ACTION_CALL Intent from that activity.

Android Intent Calling

I tried to make a call when I click on Android Mobile field with this code
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+contactNo));
startActivity(callIntent);
And added these in AndroidManifest.xml
<uses-permission android:name="packagename.permission.C2D_MESSAGE"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
And finally I am getting **java.lang.SecurityException** exception.
Why it Happens? and What is the Correct Procedure to Make a Call when click on Contact field?
use Intent.ACTION_DIAL instead of Intent.ACTION_CALL
And action_dial does not need permission, and it will show dialed phone number to user on dialer and then it will be users wish to place a call or not. This will be better approach to give user a control of what they wants to do.
hope that will help you
In order to use Intent.ACTION_CALL you have to add a permission to your manifest.
Add this permission to your manifest and it should be ok
<uses-permission android:name="android.permission.CALL_PHONE"/>

No activity found to handle geo intent in emulator

I have following simple method in my main activity.
private void showMap(String name ) {
String thePlace = name.replaceAll(" ", "+");
Intent intent= new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("geo:0,0?q=" + thePlace+ "" ));
startActivity(intent);
}
And in my manifest
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET" />
But when I run the app in emulator, it crashed and according to Log, it says
No activity found to handle the intent
Is there anything I am doing wrong?
Is geolocation enabled in emulator settings?
Well, the Maps app isn't installed on the emulator, so the message that it's giving you pretty much explains the problem. There isn't anything setup on the emulator to handle that kind of intent...

android.permission.CALL_PHONE for tablets

I am developing an app and in the manifest I have:
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
When I click on the button to execute this code:
Intent intentcall = new Intent();
intentcall.setAction(Intent.ACTION_CALL);
intentcall.setData(Uri.parse("tel:" + phonenumber)); // set the Uri
startActivity(intentcall);
It will run fine on phones, and on tablets it pops up with a display where you can view or add the number to contacts. However, if I keep the permission in the manifest, it isn't available for tablets in the market. How can I keep the code behavior and still have it display in the market for tablets as well as phones?
In the AndroidManifest you need:
<uses-feature android:name="android.hardware.telephony" android:required="false" />
The CALL_PHONE permission implies telephony is required, but if you specify that is not you won't be filtered.
Try to use Intent.ACTION_DIAL instead Intent.ACTION_CALL.
For example:
try {
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phone_number));
startActivity(intent);
} catch (Exception e) {
//TODO smth
}
And in this case you can completely remove these tags from AndroidManifest.xml:
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-feature android:name="android.hardware.telephony" android:required="false" />
Regarding "uses-feature" and it crashing - are you checking that telephony is available before actually making the call? It might be you need to do that extra step for the case when the app is on tablets. All you are saying in the manifest is that the feature is not required. It probably relies on you to actually implement the logic around that.
Instead of adding a user with the ACTION_CALL identifier, change it to ACTION_INSERT_OR_EDIT.
You'll need these permissions too, instead of the CALL_PHONE permission:
<uses-permission android:name="android.permission.READ_CONTACTS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_CONTACTS"></uses-permission>
Take a look at this related question:
can't find app on market
From google docs:
Declared elements are informational only, meaning that
the Android system itself does not check for matching feature support
on the device before installing an application
usage is only for google play

How to start 'View Contact' Activity on android?

I want to create a tab which contains a tab for viewing contact detail. Here is what i did:
intent = new Intent(Intent.ACTION_VIEW, Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_URI, ""+contactId));
nativeInfo = tabHost.newTabSpec("native info").setIndicator("N Info").setContent(intent);
It throw security exception.
I appreciate your help.
Thanks.
You need to add that permission to your manifest file, so that the user gets notified your app will read contacts when the app is installed.
<uses-permission android:name="android.permission.READ_CONTACTS" />
Take a look at this:
http://developer.android.com/guide/topics/manifest/manifest-intro.html#perms

Categories

Resources