Is it possible from your Windows Phone 7/8 application to get access to the phone call feature? I.e. if I have a string that contains a phone number, I'd like to send the user straight to the "phone" app with the number ready.
If your string is a phone number, you can simply use the code below. If your string contains a phone number you first have to extract it.
I use a regex for that. You can use my code below but you might need to change something depending on the format of your strings:
public static String GetFirstPhoneNumber(String includesnumber)
{
MatchCollection ms = Regex.Matches(includesnumber, #"([0-9][^A-Z^a-z]+)([A-Za-z]|$)");
Regex digitsOnly = new Regex(#"[^\d]");
for (int i = 0; i < ms.Count; i++)
{
String res = digitsOnly.Replace(ms[i].Value, "");
if (res.Length > 5)
return res;
}
return "";
}
You can read more about that here: A comprehensive regex for phone number validation
Here the actual PhoneCallTask:
Microsoft.Phone.Tasks.PhoneCallTask t = new Microsoft.Phone.Tasks.PhoneCallTask();
t.PhoneNumber = numbertocall;
t.DisplayName = displayname;
t.Show();
Check out 'How to use the phone call task for Windows Phone' guide at the MSDN website, I believe that's what you're looking for.
Related
i have form for customer data and i want to check if phone is exist in database(for both phone and phone 2) and even check for phone2. and if user write the same phone in both field not accepting.
here is my validation code:-
if($request->customer_id == null) {
unset($rules['customer_id']);
$rules['customer_name'] = 'required';
$rules['customer_address'] = 'required';
$rules['customer_phone'] = 'max:11|required|unique:customers,phone,phone2';
$rules['customer_phone2'] = 'max:11|unique:customers,phone,phone2';
$rules['customer_type'] = 'in:regular,special,jomla';
$mesages['customer_name.required'] = translate('the name is required');
$mesages['customer_address.required'] = translate('the address is required');
$mesages['customer_phone.required'] =translate('the phone is required');
$mesages['customer_phone.max'] =translate('the phone number is not correct');
$mesages['customer_phone.unique'] =translate('the phone number is used');
$mesages['customer_phone2.max'] =translate('the phone number is not correct');
$mesages['customer_phone2.unique'] =translate('the phone number is used');
you can try this
$rules['customer_phone'] = 'required|max:11|unique:customers,phone|unique:customers,phone2';
$rules['customer_phone2'] = 'required|max:11|unique:customers,phone|unique:customers,phone2|different:customer_phone';
The different rule ensures the phone and phone2 fields contain different values.
I have an object like:
class Person {
Phone phone;
}
class Phone {
String number;
String prefix;
Phone(String n, String p) {
number = n;
prefix = p;
}
}
Now consider this code:
Person p = new Person();
p.phone = new Phone("444444", "01");
javers.commit(p);
p.phone = new Phone("555555", "01");
javers.commit(p);
In this case sees that the reference of Phone has changed. While that's good info, I don't really care about that. I just want to know when the value of the number field has changed, that's really what I am tracking.
How would I achieve that? I tried defining the Phone class as a ValueObject, but it doesn't seem to do the job, I still get it as reference change rather than value change in the resulting Commit snapshot. Should I register it as a Value instead?
Map Phone as ValueObject or let JaVers to apply default mapping, which is also ValueObject object. ValueObject are always compared property by property and never by reference. What do you mean by it doesn't seem to do the job?
This is my code so far. Now I have a list of how many people looked at the page (article) but I wondered if it's possible to make a list of links of a wikipedia page (article) and how many times there is clicked on the links?
String[] articles = {"Hitler", "SOA", "Albert_Einstein"};
void setup() {
for (int i = 0; i < articles.length; i++) {
String article = articles[i];
String start = "20160101"; // YYYYMMDD
String end = "20170101"; // YYYYMMDD
// documentation: https://wikimedia.org/api/rest_v1/?doc#!/Pageviews_data/get_metrics_pageviews_per_article_project_access_agent_article_granularity_start_end
String query = "http://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/en.wikipedia/all-access/all-agents/"+article+"/daily/"+start+"/"+end;
JSONObject json = loadJSONObject(query);
JSONArray items = json.getJSONArray("items");
int totalviews = 0;
for (int j = 0; j < items.size(); j++) {
JSONObject item = items.getJSONObject(j);
int views = item.getInt("views");
totalviews += views;
}
println(article+" "+totalviews);
}
}
To get the links from an article use action=query in the API together with props=links.
In your example: https://en.wikipedia.org/w/api.php?action=query&format=json&prop=links&meta=&titles=Albert+Einstein%7CHitler%7CSOA&pllimit=500
Do note that this is not all results (you can only get 500 at a time) so you need to make more requests using the plcontinue you get as a parameter in the new request.
Break your problem down into smaller steps.
Create a single program that just returns all of the links on a wikipedia page. Make sure you have that program working perfectly, and post an MCVE if you get stuck.
Separately from that program, create a separate program that takes a hardcoded URL and returns the number of views that URL has. Again, post an MCVE if you get stuck. When you get that working, move up to a program that takes a hardcoded ArrayList of URLs and returns the pageviews for each URL.
Then when you have them both working separately, then you can start thinking about combining them.
I am using Google CSE v2, and I need to get the query that the user entered. The problem is that it is ajax, and the query is not in the url.
Does anyone know a solution?
Thanks
First off, when you create the search box, you need to give it a 'gname' attribute so you can identify it in your javascript, like so:
<gcse:searchbox gname="storesearch"></gcse:searchbox>
<gcse:searchresults gname="storesearch"></gcse:searchresults>
Or, if you're using the html5 style tags (which you should unless you have a reason not to):
<div class="gcse-searchbox" data-gname="storesearch"></div>
<div class="gcse-searchresults" data-gname="storesearch"></div>
(Replace 'storesearch' with whatever name you want to use to identify this custom search.)
More info on that here: https://developers.google.com/custom-search/docs/element#supported_attributes
Then, you can access the custom search element and get the current query like so:
var cseElement = google.search.cse.element.getElement('storesearch'),
query = cseElement.getInputQuery();
or if you don't need the reference to the element anymore, obviously that could be combined into one line:
var query = google.search.cse.element.getElement('storesearch').getInputQuery();
The docs for that part are here: https://developers.google.com/custom-search/docs/element#cse-element
I know this is already answered correctly. But for those also looking for a simple JS function to achieve this, here you go. Pass it the name of the variable you want to extract from the query string.
var qs = (function(a) {
if (a == "") return {};
var b = {};
for (var i = 0; i < a.length; ++i) {
var p=a[i].split('=');
if (p.length != 2) continue;
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
}
return b;
})(window.location.search.substr(1).split('&'));
I'm having a list
var library = new List<string>() { "personal assistant", "sales manager", "engineer" };
and a text which is declared as
string target = "I'm a personal assistant to sales manager"";
I need to match the list with the text and should return the match count.
For the above sample i should get a count of 2 since target is having personal assistant and sales manager.
Maybe something like this:
int count = library.Count(s => target.Contains(s));
This one doesn't check for multiple occurrences of one string, though.