Invoke on UI Thread on Xamarin
Posted May 19, 2017
on:I was getting Error on Xamarin Android running very slow:
[Choreographer] Skipped 87 frames! The application may be doing too much work on its main thread.
[Choreographer] Skipped 89 frames! The application may be doing too much work on its main thread.
[Choreographer] Skipped 82 frames! The application may be doing too much work on its main thread.
[Choreographer] Skipped 87 frames! The application may be doing too much work on its main thread.
[Choreographer] Skipped 87 frames! The application may be doing too much work on its main thread.
[ResourceType] No package identifier when getting value for resource number 0x00000000
[Choreographer] Skipped 86 frames! The application may be doing too much work on its main thread.
[Choreographer] Skipped 93 frames! The application may be doing too much work on its main thread.
[Choreographer] Skipped 92 frames! The application may be doing too much work on its main thread.
[ResourceType] No package identifier when getting value for resource number 0x00000000
[Choreographer] Skipped 84 frames! The application may be doing too much work on its main thread.
[Choreographer] Skipped 89 frames! The application may be doing too much work on its main thread.
[Choreographer] Skipped 87 frames! The application may be doing too much work on its main thread.
Then I found this very good article i have found for: UI Thread. that resolved my issue.
https://forums.xamarin.com/discussion/17403/invoke-on-ui-thread?
- copy and paste below code:
/// <summary>
/// Method to run on main thread for android
/// </summary>
/// <returns>The invoke on main thread async.</returns> /// <param name=“action“>Action.</param>
public Task BeginInvokeOnMainThreadAsync(Action action){ TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();
Device.BeginInvokeOnMainThread(() => {
try {
action();
tcs.SetResult(null);
}
catch (Exception ex) { tcs.SetException(ex);
}
});
return tcs.Task;
}
2. Second call your method like this:
MyMethod();
BeginInvokeOnMainThreadAsync(() => MyMethod(true));
- In: IOS | Xamarin
- Leave a Comment
The reason for IOS 9 Simulator is not working because Apple has included Transport Security in it.
Transport Security
App Transport Security (ATS) lets an app add a declaration to its Info.plist
file that specifies the domains with which it needs secure communication. ATS prevents accidental disclosure, provides secure default behavior, and is easy to adopt. You should adopt ATS as soon as possible, regardless of whether you’re creating a new app or updating an existing one.
If you’re developing a new app, you should use HTTPS exclusively. If you have an existing app, you should use HTTPS as much as you can right now, and create a plan for migrating the rest of your app as soon as possible.
To fix open info.plist and add the following:
- <key>NSAppTransportSecurity</key>
- <dict>
- <key>NSAllowsArbitraryLoads</key><true/>
- </dict>
That’s all.
Under your .js file you need something like this:
//————————————————————————————————–
//TABLE
//—————————————————————————————————
function DisplayTablesList() {
//get selected ddname
var mydd = GetDDNameAllTables();
//empty div contents
EmptyDivData(‘#tbllist-div’);
//show loading image
showLoadingImage(‘#tbllist-div’);
$.ajax({
url: “webservices/ServiceSearch.asmx/GetAllTableNames”,
data: “{‘myddname’:'” + mydd + “‘}”,
dataType: “json”,
type: “POST”,
contentType: “application/json; charset=utf-8”,
async: true,
success: function (data) {
var obj = jQuery.parseJSON(data.d);
//obj[0][“ColumnName”]
var returnlist = new Array();
var $table = $(‘<Table class=”table table-condensed” ></Table>’);
for (var i = 0; i < obj.length – 1; i++) {
var rownumber = i + 1;
//alert(obj[i][“ColumnName”]);
returnlist.push(obj[i][“ColumnName”].toString());
$table.append(‘<tr><td>’ + rownumber.toString() + ‘. ‘ + ‘<a href=”Table.aspx?name=’ + obj[i][“ColumnName”].toString() + i + ‘”>’+ obj[i][“ColumnName”].toString() + i + ‘</a>’ + ‘</td></tr>’);
}
$table.append(‘(<a href=”#top-filter-a-z”>Go to Top</a>)’);
$(‘#tbllist-div’).append($table);
//hide loading image
hideLoadingImage();
}, error: function (result) {
//alert(“Error: Please contact administrator for help: ” + result.responseText);
}
});
}
Under your .asmx file (web service file) you need to declare a method to return JavaScriptSerializer().Serialize(e)
‘—————————————————————————————————
‘METHOD TO GET ALL TABLE NAMES FULL LIST
‘—————————————————————————————————
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Public Function GetAllTableNames(ByVal myddname As String) As String
Dim result As New List(Of String)()
LoadOracleSettingsFromWebConfig(myddname)
Dim oradb As String = “Data Source=(DESCRIPTION=” _
+ “(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=” + _oraclehost + “)(PORT=” + _oraclehostport + “)))” _
+ “(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=” + _oracleservicename + “)));” _
+ “User Id=” + _oracleuserid + “;Password=” + _oracleuserpassword + “;”
Dim conn As New OracleConnection(oradb)
Dim i As Integer = 0
Dim return_max_count As Integer = 0
Try
Using con As New OracleConnection(oradb)
Using cmd As New OracleCommand(“select DISTINCT table_name from mytblnamehere order by table_name”, con)
con.Open()
Dim dr1 As OracleDataReader = cmd.ExecuteReader()
Dim dr As OracleDataReader = cmd.ExecuteReader()
While dr1.Read()
Try
return_max_count = return_max_count + 1
Catch ex As Exception
‘dont’ do anything
End Try
End While
Dim e As TableClass() = New TableClass(return_max_count) {}
While dr.Read()
e(i) = New TableClass()
e(i).ColumnName = dr(“table_name”).ToString
i = i + 1
End While
Return New JavaScriptSerializer().Serialize(e)
End Using
End Using
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
End Function
In this case if you have your .apk file that you need to upload to your device.
In my case i am using IPhone they way you will upload is that.
Build your mobileapp.apk file to some folder.
Open XCode and go to Window > Organizer
Hold your .apk file can drag on to “Application” on IPhone device.
Shortly you will see your app is installed on to yours IPhone.
- In: SAS
- Leave a Comment
How to load any sas dataset into oracle schema.
/* create lib name */
Libname ora oracle user = ORASCHEMA
password = “*************”
path = ORASERVERNAME
schema = MYNAME
connection = unique;
/* read sas dataset into workspace */
data my_sas_dataset_name;
set input.my_sas_data_set_name;
run;
/* load dataset into oracle database*/
proc sql;
create table ora.my_sas_table_name
(BULKLOAD=YES BL_OPTIONS=’ERRORS=899,LOAD=5000′) as
select * from my_sas_dataset_name;
quit;
That’s all.
How to show hidden files on mac
Posted April 23, 2014
on:- In: Mac
- Leave a Comment
open terminal window on your mac.
to show hidden files type:
defaults write com.apple.finder AppleShowAllFiles TRUE
to hide hidden files type:
defaults write com.apple.finder AppleShowAllFiles FALSE
- In: WebHosting
- 1 Comment
How to use your free BlueHost SSL Certificate: Well I have work around my url to figure it to make it work.
This is what instruction is on bluehost.com: https://my.bluehost.com/cgi/help/126
But actually what you need to figure it out two things:
1. your user name which is very simple to find under your cPanel.
2. They ask you to user url something like this: https://secure.BlueHost.com/~username.
Well it’s not clear and not worked for me. So what i had to do to make it work is login under you cPanel and
Note in image of url on your cPanel ! you have something like box724
I have used that instead of secure.bluehost and it worked for me.
Try it yours and see it should work. So you will type something like: https://box274.blueshot.com/~yourusername
Enjoy!
I upload the app on apple store and received this message not sure what exactly this mean.
Apps are not permitted to access the UDID and must not use the uniqueIdentifier method of UIDevice. Please update your apps and servers to associate users with the Vendor or Advertising identifiers introduced in iOS 6. If method names in your source code match the private Apple APIs listed above, altering your method names will help prevent this app from being flagged in future submissions. In addition, note that one or more of the above APIs may be located in a static library that was included with your app. If so, they must be removed.
But then i google and i found out:
Use of the device’s uniqueidentifier
property in apps was deprecated in iOS 5.0 and forbidden in iOS 6 apps as of 1 May 2013. Instead, you can use the identifierForVendor
property available in iOS 6.0. Apple changed the API to address privacy concerns.
How i fixed it:
My problem with this was due to the adMob library. It was fixed in adMob SDK 6.4.2. From Google:
The AdMob SDK for iOS utilizes Apple’s advertising identifier (IDFA). The SDK uses IDFA under the guidelines laid out in the iOS developer program license agreement. Developers must ensure they are in compliance with the iOS developer program license agreement policies governing the use of this identifier.
Loading an image from a url with MonoTouch on the iPhone
To load an image into a UITableViewCell use the code below to load image from url.
NSUrl nsUrl = new NSUrl(weburl);
NSData imgdata = NSData.FromUrl(nsUrl);
var myImage = new UIImage(imgata);
cell.ImageView.Image= myImage;
java.lang.UnsatisfiedLinkError: Couldn’t load mono: findLibrary returned null
Posted November 30, 2012
on:- In: Mono
- Leave a Comment
Some times you will see this error message “java.lang.UnsatisfiedLinkError: Couldn’t load mono: findLibrary returned null” after you deploy your android app.
The reason for this is that when you publish your app you have selected supported ABIs armeabi-v7a, armeabi and x86 and if user install your app on ARMv6 device it gives this error.
There is no workaround that I have found in Mono Develop to stop this error.
Just fyi!