When I give number="05338830967"; is like it is working but when I give this number number="03926502323"; it is not running, phone tell me that create internet call what is it?
private void makePhoneCall(String number) {
try {
for (int i = 0; i < number.length(); i++) {
if ( number.contains("-")) {
String[] numaraduzelt = number.split("-");
number= numaraduzelt[0]+numaraduzelt[1];
}
}
number="tel:+9"+number;
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(number));
}
}
You may want to use the excellent libphonenumber library from Google that is being used everywhere including the Android framework for parsing and formatting phone numbers. This would allow you to validate the phone number before you attempt to send a dialing Intent.
Related
Is there any way to automatically detect OTP in a webview?
There is a mobile no. to be verified using a an OTP and OTP is to be detected in in app webview.
Thanks in advance
Whenever you get OTP via sms and notify by receiver, then inside webview whichever input text inside you want to add your OTP there you need to do something like this?
String otp = "OTP_FROM_YOUR_RECEIVER";
webview.loadUrl("javascript:document.getElementById('otp_input').value = '"+otp+"';");
Above code is just example you need to change as per your requirements and all.
Here the code in Kotlin:
if (Build.VERSION.SDK_INT >= 19) {
mWebView!!.evaluateJavascript(getString(R.string.fill_otp) + "\"$extractedOTP\";") { Log.e(TAG, it) }
} else {
mWebView!!.loadUrl(getString(R.string.fill_otp) + "\"$extractedOTP\";")
}
Put "fill_otp" in strings file:
<string name="fill_otp">javascript: function getInputs() {
var ary = [];
var inputs = document.getElementsByTagName(\"input\");
for (var i=0; i<inputs.length; i++)
{
if (inputs[i].type.toLowerCase() == \"password\"||
inputs[i].type.toLowerCase() == \"tel\"||
inputs[i].type.toLowerCase() == \"number\"||
inputs[i].type.toLowerCase() == \"text\"){
if(!inputs[i].hidden&&!inputs[i].disabled){
ary.push(inputs[i]);
}
}
}
return ary;
}
var array= getInputs();
array[0].value=</string>
I have a python server and about 10 android clients, using sockets. It is really important that when the server sends a message, all clients receive it at the same time (say 1/10th of a second of difference).
But the connection is over Wifi, and some devices get the message later than others, which gives a very messy result. I don't want to get the latency of every device because this is a very unreliable approach. I want something as accurate as possible.
For example, in FPS games, it is common to have a countdown at the start of the round, and every player can start playing at the same time. What kind of logic lies behind this?
As for what my code currently looks like:
I use a BufferedReader in android to read every line sent by the server. The server is a console application in which you can type a message, and when you press enter, every listed client receives it with a new thread for every client.
java method receiving messages:
private void readMessage() throws IOException {
String data;
while ((data = mBufferedReader.readLine()) != null) {
data = data.toUpperCase();
if (data.startsWith("POSITION")) {
String[] splitData = data.split("/");
Log.d(Constants.TAG, splitData[1]);
mMainActivity.setDevicePosition(Integer.parseInt(splitData[1]));
} else {
String message = data.substring(data.indexOf('/') + 1, data.length());
int devices = Integer.parseInt(data.substring(0, data.indexOf('/')));
if (message.length() >= devices) {
message += " ";
} else {
int difference = devices - message.length();
for (int i = 0; i < difference; i++) {
message += " ";
}
}
mMainActivity.printMessage(message);
}
}
}
python line :
for cl in clients_list:
start_new_thread(send_message_thread, (cl, message,))
I'm developing a Xamarin Android app and I need the ability to be able to work with Passes (PassKit passes for example (JSON)). I need to be able to list all the passes in a ListVew and be able to open and display the pass. Also be able to save them to a wallet such as PassWallet or Pass2u. I don't need the ability to create them, just view them, and save them to a wallet or discard them.
There seems to be an example Xamarin iOS app which does exactly what i need here but of course I need to be able to do this in Xamarin Android.
I've been researching this for hours but don't know how to achieve what i need. JSON.net seems the way to go to read the passes, but that's as far as I've managed to get. Some examples would be great. Can anybody help?
To add the pass into PassWallet you can use the following:
private static boolean launchPassWallet(Context applicationContext, Uri uri, boolean launchGooglePlay) {
if (null != applicationContext) {
PackageManager packageManager = applicationContext.getPackageManager();
if (null != packageManager) {
final String strPackageName = "com.attidomobile.passwallet";
Intent startIntent = new Intent();
startIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startIntent.setAction(Intent.ACTION_VIEW);
Intent passWalletLaunchIntent = packageManager
.getLaunchIntentForPackage(strPackageName);
if (null == passWalletLaunchIntent) {
// PassWallet isn't installed, open Google Play:
if (launchGooglePlay) {
String strReferrer = "";
try {
strReferrer = "&referrer=" + URLEncoder.encode(uri.toString(), "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
strReferrer = "";
}
try {
startIntent.setData(Uri.parse("market://details?id=" + strPackageName + strReferrer));
applicationContext.startActivity(startIntent);
} catch (android.content.ActivityNotFoundException anfe) {
// Google Play not installed, open via website
startIntent.setData(Uri.parse("http://play.google.com/store/apps/details?id=" + strPackageName + strReferrer));
applicationContext.startActivity(startIntent);
}
}
} else {
final String strClassName = "com.attidomobile.passwallet.activity.TicketDetailActivity";
startIntent.setClassName(strPackageName, strClassName);
startIntent.addCategory(Intent.CATEGORY_BROWSABLE);
startIntent.setDataAndType(uri, "application/vnd.apple.pkpass");
applicationContext.startActivity(startIntent);
return true;
}
}
}
return false;
}
And an example call is:
launchPassWallet(getApplicationContext(),Uri.parse("http://test.attidomobile.com/PassWallet/Passes/AttidoMobile.pkpass"), true);
You can also use a file:// URL if you have the file locally.
To display them in the list, you'd need to unzip the .pkpass file and then parse the JSON for the relevant fields.
I'm developping an android game in witch I connect to facebook . If the user is connected , he can invite 5 of his facebook to the application. I used this code. The problem that in the script InteractiveConsole.cs I want when the user click on button of invite , he can invite only 5 of his friends, when he choose 5 friends , he can't invite more than 5.
Here is my code:
#region FB.AppRequest() Friend Selector
public string FriendSelectorTitle = "";
public string FriendSelectorMessage = "Derp";
public string FriendSelectorFilters = "[\"all\",\"app_users\",\"app_non_users\"]";
public string FriendSelectorData = "{}";
public string FriendSelectorExcludeIds = "";
public string FriendSelectorMax = "";
private void CallAppRequestAsFriendSelector()
{
// If there's a Max Recipients specified, include it
int? maxRecipients = null;
if (FriendSelectorMax != "")
{
try
{
maxRecipients = Int32.Parse(FriendSelectorMax);
}
catch (Exception e)
{
status = e.Message;
}
}
// include the exclude ids
string[] excludeIds = (FriendSelectorExcludeIds == "") ? null : FriendSelectorExcludeIds.Split(',');
FB.AppRequest(
FriendSelectorMessage,
null,
FriendSelectorFilters,
excludeIds,
maxRecipients,
FriendSelectorData,
FriendSelectorTitle,
Callback
);
}
#endregion
Thanks for your help.
I Found out why it's not working.
First to limit the numbers of friends invited to 5 in my application , i should change this:
public string FriendSelectorMax = "5";
i cheked again the documententation and it say this.
"maxRecipients : Platform-dependent The maximum number of recipients the user should be able to choose in the platform multi-friend selector dialog. Only guaranteed to work in Unity Web Player applications."
Here is the link : https://developers.facebook.com/docs/unity/reference/current/FB.Apprequest
the think is that maxRecipients is working in WebPlayer and not for android until now.
I tested the code in unity web player and i can invite only 5 friends and when i switch the platform to android, it's not working as they said in the documentation.
I had gotten reports from a few users that they couldn't login to our app (which makes HTTP calls to our site) or visit our website in their browser, so I added some code to our latest build to check what IP our host name is resolving to. I've gotten reports from several different users now that they get 127.0.0.1 for our hostname when the app starts, which obviously isn't going to work.
They claim they aren't running any proxy software, and this happens on both 2.1 and 2.2. This also happens on both wifi & 3g, which makes me suspect it is some piece of software on their phone that is interfering with DNS resolution somehow. Does anyone know of any popular software that might do that? Or does anyone have any ideas about how to identify which software might be doing it?
Thanks,
import org.xbill.DNS.Lookup;
import org.xbill.DNS.Record;
import org.xbill.DNS.TXTRecord;
import org.xbill.DNS.TextParseException;
import org.xbill.DNS.Type;
public class DNSLookUpActivity extends Activity {
private String url = "https://spectracore.americanlogistics.com/rdac/AdmissionController/CheckMddAdmission";
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
funDNS(url);
}
private static void funDNS(String url) {
try {
Lookup lookup = new Lookup(url, Type.ANY);
Record[] records = lookup.run();
if (lookup.getResult() == Lookup.SUCCESSFUL) {
String responseMessage = null;
String listingType = null;
for (int i = 0; i < records.length; i++) {
if (records[i] instanceof TXTRecord) {
TXTRecord txt = (TXTRecord) records[i];
for (Iterator j = txt.getStrings().iterator(); j
.hasNext();) {
responseMessage += (String) j.next();
}
Log.e("TXRecord ", "" + responseMessage);
} else if (records[i] instanceof ARecord) {
listingType = ((ARecord) records[i]).getAddress()
.getHostAddress();
Log.e("ARecord address : ", "" + listingType);
}
}
}
} catch (TextParseException e) {
e.printStackTrace();
}
}
}
Need android ask version 2.3.3 or above
Get their DNS config, and try their DNS servers directly with dig or nslookup. This is not perfect, but it has a good chance of showing you the problem.
dnsjava/org.xbill.DNS is too big for android app, Scott Means's DNSQuery is promiseful:
http://smeans.com/programming/dns-queries-in-java/