Accessing iPhone and android phonebook in as3 - android

I want to fetch all contacts in iPhone and android phonebook in my application in AS3. How can this be done in as3?
-Thanks in advance

You're going to need to use a Native Extension.
Check this one out:
https://github.com/memeller/ContactEditor

For iPhone, first you have to add Addressbook and AddressbookUI framework.
Then, for fetching contacts, you have to implement following methods...
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
then,, - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person
and at last - (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker
Now, set return NO
in Second method, call one method....like
[self displayContact:person];
[self dismissModalViewControllerAnimated:YES];
return NO;
and in Third view, set this..[self dismissModalViewControllerAnimated:YES];
Now, for that method...
-(void)displayContact:(ABRecordRef)person
{
name = (__bridge_transfer NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
lblname.text = name;
ABMultiValueRef phNumbers = ABRecordCopyValue(person, kABPersonPhoneProperty);
if(ABMultiValueGetCount(phNumbers) > 0)
{
//NSLog(#"Count is:%ld",ABMultiValueGetCount(phNumbers));
phone = (__bridge_transfer NSString *)ABMultiValueCopyValueAtIndex(phNumbers, 0);
btnsms.hidden = NO;
btnedit.hidden = NO;
}
else
{
phone = #"[NONE]";
}
lblphno.text = phone;
}
By implementing this, you can see name and phone no.in your labels....:)

Related

Speeding up table view cell loading with UINib

I am developing iPhone chat application.
After run an app, when I clicked any chat room, there is exist delay for 1~2sec while opening the chat room.
This delay will occur only first time after run.
After back to chat room list, when I clicked any chat room again, there is no exist delay.
When I see the whatsapp, there is no any delay and opened the chat room immediately as soon as clicked chat room.
Now, on viewWillAppear, Current chat room messages has been fetched from DB and I called reloadData of UITableView.
Anyone know why there are exist delay?
Or Anyone know perfect architecture to open chat room without any delay?
Please advice me, Thank you.
ChatRoomsViewController class
- (void)viewDidLoad {
...
self.chat_board = [[ChatBoardViewController alloc] initWithNibName:#"ChatBoardViewController" bundle:nil];
UINib *nib = [UINib nibWithNibName:#"ChatBoardRightCell" bundle:nil];
[_chat_board.board_table registerNib:nib forCellReuseIdentifier:#"ChatBoardRightCell"];
nib = [UINib nibWithNibName:#"ChatBoardLeftCell" bundle:nil];
[_chat_board.board_table registerNib:nib forCellReuseIdentifier:#"ChatBoardLeftCell"];
...
}
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
...
dispatch_async(dispatch_get_main_queue(), ^{
OrientationEnabledNavigation *navcon = (OrientationEnabledNavigation*)self.tabBarController.selectedViewController;
[navcon pushViewController:_chat_board animated:isAnim];
});
...
}
ChatBoardViewController class
- (void)viewWillAppear:(BOOL)animated {
...
[time_sections removeAllObjects];
_messageTotalCount = [[ChatStorage sharedStorage] getMessageCount:chat_id];
if (self.isLoadAll) {
self.showingCount = _messageTotalCount;
[time_sections addObjectsFromArray: [[ChatStorage sharedStorage] getTimeGroups:chat_id count:_messageTotalCount]];
}else{
[time_sections addObjectsFromArray: [[ChatStorage sharedStorage] getTimeGroups:chat_id count:self.showingCount]];
}
[self reloadData];
...
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
...
NSString *identifier = is_owner ? #"ChatBoardRightCell" : #"ChatBoardLeftCell";
ChatBoardCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
NSString * parsed_msg = [record objectForKey:#"parsed_message"];
NSDictionary * decoded = [[ChatStorage sharedStorage] decodeStringToDictionary:parsed_msg];
[cell setText:decoded editMode:_edit_mode];
...
return cell;
}

Go-Ethereum: Android Smart Contract Interaction Issue

I am attempting to interact with a smart contract via mobile (android) using the go-ethereum library.
Android
final String address_string = "0x8607e627604495ae9812c22bb1c98bdcba581978";
String abi = "[{\"constant\":false,\"inputs\":[],\"name\":\"get_s\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"new_s\",\"type\":\"string\"}],\"name\":\"set_s\",\"outputs\":[],\"payable\":false,\"type\":\"function\"},{\"inputs\":[{\"name\":\"d_s\",\"type\":\"string\"}],\"payable\":false,\"type\":\"constructor\"}]";
Address address = Geth.newAddressFromHex(address_string);
BoundContract contract = Geth.bindContract(address, abi, ec);
CallOpts callOpts = Geth.newCallOpts();
callOpts.setContext(ctx);
callOpts.setGasLimit(31500);
System.out.println("OUTPUT: " + getString(contract, callOpts));
//Setter String to Test Contract
Interfaces params = Geth.newInterfaces(1);
Interface anInterface = Geth.newInterface();
anInterface.setString(teststring);
params.set(0,anInterface);
return contract.transact(opts, "set_s", params);
//Getter String from Test Contract
Interfaces args = Geth.newInterfaces(0);
Interfaces results = Geth.newInterfaces(1);
Interface result = Geth.newInterface();
result.setDefaultString();
results.set(0, result);
contract.call(opts, results, "get_s", args);
String string = results.get(0).getString();
return string;
Contract
pragma solidity ^0.4.9;
contract echo {
string s;
function echo(string d_s) {
s = d_s;
}
function set_s(string new_s) {
s = new_s;
}
function get_s() returns (string) {
return s;
}
}
Expected behaviour
Successful interaction with a deployed smart contract on the Rinkeby blockchain.
Actual behaviour
For setter (on contract):
'abi: cannot use slice as type string as argument'
For getter (on contract):
'abi: cannot unmarshal string in to []interface {}'
Steps to reproduce the behaviour
1.) Connect to Rinkeby Testnet via mobile
2.) Create an account via mobile
3.) Deploy a smart contract via desktop
4.) Try to interact w/ the smart contract via mobile
Bottom Line
If anyone has been able to interact with smart contracts through go-ethereum android,
I would appreciate some assistance.
fix for that issue.
https://github.com/ethereum/go-ethereum/pull/15402
I'm waiting for feedback.

Cordova Json . array local storage isn´t workind on android

I´m trying to do an array to storage data with local storage. it works pretty well on google emulator. but isn´t working on my android device.
I found this code on the internet to put array in localstorage, and it works.
Storage.prototype.setArray = function (key, obj) {
return this.setItem(key, JSON.stringify(obj))
}
Storage.prototype.getArray = function (key) {
return JSON.parse(this.getItem(key))
}
then i create an function to get and set the data there.
function teste() {
var bd = [];
bd = window.localStorage.getArray("banco");
var nome = $('#name2').val();
alert(nome);
var area = $('#textarea2').val();
alert(area);
var meuservico = new servico(nome, area);
bd.push(meuservico);
alert(bd[0].nome);
window.localStorage.setArray("banco", bd);
}
and I also made an object called service.
function servico(nome,area){
this.nome = nome;
this.area = area;
}
this code work! but only on browser . how do I make it work on android? I don´t really wanna work with strings in localstorage. please help me!.
I tried with this too and didn´t work on device either.
localStorage.setItem('session', JSON.stringify(session));
var restoredSession = JSON.parse(localStorage.getItem('session'));

Appium Android Automation

This may be simple question for the experts. I am a beginner in appium and all these days i have been trying to make my test script for printing a page title in my script. Here is the part of My code below: i am unable to print the page title and then do a validation. Can someone help?
driver = new AndroidDriver<WebElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
System.out.println(driver.getRemoteAddress());
}
public void ApkPushValidation() throws Exception {
Assert.assertEquals("Verify your phone number", driver.findElementByName("Verify your phone number").getText());
driver.wait(5000);
String i = driver.getTitle();
System.out.println(i);
if (driver.getTitle().equals("Verify your phone number") ) {
System.out.println("app installation is passed");
} else {
System.out.println("App installation is failed");
}
//System.out.println(i);---> my expectation is that this will print out Verify your Phone number. However this is not printing the page title.
Use UIAutomatorViewer to find out the xpath of the title.
use the following website for example on how to use the x-path. "http://software-testing-tutorials-automation.blogspot.ca/2015/10/ui-automator-viewer-get-android-app.html"
I think that driver.getTitle() is a method for Web page interaction, not meant for Native apps. I would suggest to use XPath or some other element locator to find the title.
Instead if getTitle(); try to use xPath, name or Id available for the title. Use Appium inspector or UI automator to locate that element and change it like this:
String i = driver.findElementById("Your ID").getText();
if (i.equals("Verify your phone number") ) {
System.out.println("app installation is passed");
} else {
System.out.println("App installation is failed");
}
What you probably what to perform should be done using the following piece of code :
WebElement title = driver.findElementByName("Verify your phone number"); // defining the element only once for multiple use
// different locator strategies could be used for locating the element above
Assert.assertEquals("Verify your phone number", title.getText());
driver.wait(5000);
String i = title.getText();
System.out.println(i);
if (i.equals("Verify your phone number") ) {
System.out.println("app installation is passed");
} else {
System.out.println("App installation is failed");
}
More on driver.getTitle() : It has been inherited from RemoteWebDriver and possibly should return the title of a webpage/webview instead of an native application view which seems to be your case.
Note: would add more to this about getTitle() as I get to know.

nginx redirect from web to mobile application

There are Android and iOS applications, I have dynamical URI and I need to redirect Android and iOS users directly to mobile application via nginx, only if they use this link.
But I don't understand how to handle it without "logical and" or "inner if".
As I understand I have to solve two conditions:
if ($http_user_agent ~* '(iphone|ipod|nokia|аndroid)' ) {
rewrite ^ mobile_application://$host$request_id last;
}
and:
set $my_uri sign-up?invitation=$key #this key is dynamical
if ($request_id = '($my_uri)' ) {
rewrite ^ mobile_application://$host$request_id last;
}
So, I have no idea how to fix it.
set $targeted_mobile no;
if ($http_user_agent ~* "android|iphone|ipod") {
set $targeted_mobile yes;
}
location /deep-link/ {
if ($targeted_mobile = yes) {
rewrite ^/deep-link/(.*) mobile://www.aaa.com/$1 permanent;
}
rewrite ^/deep-link/(.*) https://$server_name/$1 permanent;

Categories

Resources