error in using toInt() function in android developement(Kotlin) - android

I am getting error when i use toInt() function in android(Kotlin)
val num1=findViewById<EditText>(R.id.num1).text.toString()
val num2=findViewById<EditText>(R.id.num2).text.toString()
when i add toInt()
val num1=findViewById<EditText>(R.id.num1).text.toString().toInt()
val num2=findViewById<EditText>(R.id.num2).text.toString().toInt()
i am getting error when i run my app on my phone.
I am a newbie in android developement so i decided to make a simple app which calculate two numbers but when i try to use toInt() my app not run on my phone
Note:when i remove toInt() my app smoothly run on my phone.
[enter image description here][1]
screen shoot of error i am getting
[1]: https://i.stack.imgur.com/Sl3cn.jpg

Is it possibly crashing while attempting to cast empty field values as numbers?
Try using toIntOrNull and let me know what happens.

Related

Line break (\n) not working in ios when escaped via StringEscapeUtils.escapeJava

I am using compile 'org.apache.commons:commons-lang3:3.4' library to convert emoji from my android app so that it can easily decoded in ios. So in my android app to encode string into unicode i am using this method StringEscapeUtils.escapeJava its working fine emoji sent via android app showing in ios but when i sent data which contains some line break, in ios it shows \n instead of showing text in new line.I tried
val actualText=editText.text.toString()
val oldText=StringEscapeUtils.escapeJava(actualText).toString()
val newText=oldText.replace("\n", "\r\n")
but its not working.
After struggling a lot i found the issue.
for these statements:
val actualText=editText.text.toString()
val oldText=StringEscapeUtils.escapeJava(actualText).toString()
val newText=oldText.replace("\n", "\r\n")
This picture(output) will clear everything
after using StringEscapeUtils.escapeJava for old text \n not considered as escape sequence character. So i changed replacement statement to:
val reviewText=oldText.replace(StringEscapeUtils.escapeJava("\n"), "\r\n")
and then output is:
after this in ios app instead of showing \n it shows text to the new line.

ionic android unexpected token

I am using the Ionic Framework to build a mobile app for Android/iOS. I was able
to build the project for android (ionic build android). When I run the app, it will be only a white screen, that's because there is an error (when you use GapDebug, you can run apps on your phone and you will be able to debug, and see errors). Now if I run it on the desktop browser there really is NO error and everything is working. Below is the error that is shown in GapDebug:
Now when you check the code in service.js line 394:
There's nothing wrong with the code right? If I try to change line 394 to something like key : self.currentUser, there will be NO error and the app will work. What seems to be the problem here?
Not sure why you are making an object's attribute a list? If you want the key to be childQuestionSnapshot.key then remove the square brackets.
If you are trying to update a list of objects, you can do something similar to the below:
var test = [{key: 'thisguy'},{key: 'thatguy'},{key: 'myguy'}]
test.forEach(function(item){
item['key']='newguy'
})
console.log(test)
Do this instead
var updateObj = {};
updateObj[childQuestionSnapshot.key] = self.currentUser;
applicantRef.update(updateObj, function() {
console.log("applicant answers updated");
});

Calabash android hybrid app with IONIC framework. unable to access elements

I am trying to test a hybrid app (created with ionic cordova) with calabash.
I am not able to see any elements in the console. Any query statement returns [] Below is the code snippet of what I did. Let me know what is wrong.
D:\ionicProject\todo\platforms\android\build\outputs\apk>calabash-androi
d console android-debug.apk ADB_DEVICE_ARG=emulator-5554
Starting calabash-android console...
Loading C:/Ruby21/lib/ruby/gems/2.1.0/gems/calabash-android-0.5.15/irbrc
Running irb...
*** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansic
on/) to get coloured output on Windows
irb(main):001:0> start_test_server_in_background
nil
irb(main):002:0> query("webView css:'*'")
[]
irb(main):003:0> query("CordovaWebView css:'*'")
[]
First simply use query('*') and see all the result.
Then find all the element with class using
query('*', :class)
Then find all the element with class using
query('*',:id)
If you want to display only text content
query('*', :textContent)
if you know the correct view (ie webview or systemview) You can use that view name instead of *
Need to use SystemWebView instead of CordovaWebView
Example:
query("SystemWebView css:'*'")

Show image in TImage dynamically (at run time) without opendialog in c++ builder xe8

I want to show image (png,jpg etc) in dynamically created (as per requirement and fully through coding) TImage component, at runtime in C++ builder xe8 (not delphi). But I dont want to use opendialogbox (suggested in many web sites). I want to run this app on my android device. I tried to use LoadFromFile(), it crashes the app on android, but when I run this on windows, its running smoothly. I am just a beginner to c++ builder. So guys pls help. Thanx in advance for any kind of help.Here is what I did.
void __fastcall TForm1::TForm1(TComponent* Owner)
{
TImage* img = new TImage(this);
img->Parent = this;
img->Bitmap->LoadFromFile("D:\\res\\profile.png");
}
Did you see what is the error?
If you run the program with the provided by you code I assume the error would be that the file is not found, because there is no such directory "D:\" in android.
One way to set the path is to write a static path which points to your image. For example : "/storage/sdcard0/DCIM/Camera/MyImage.jpg";
The second way is to include the <System.IOUtils.hpp> header and to use some built-in functions like:
System::Ioutils::TPath::GetPicturesPath();
System::Ioutils::TPath::GetAlarmsPath();
You can check them out, they might be useful.

why is my titanium application going into infinite loop wer it works fine in the iphone?

i'm starting up in titanium and i successfully created an app, or i thought so....
i launched application in iphone and the code is working fine with no issues.
but wen i deployed the appin android my application is going into infinite loop of creating windows.
all the code works fine until i used this piece of code in creating a new window of tabs..
var win=Ti.UI.currentWindow;
win.backgroundImage='goldmenubackground.jpg';
var win_zipsearch=Ti.UI.createWindow({backgroundImage:'goldmenubackground.jpg'});
var win_search=Ti.UI.createWindow({backgroundImage:'goldmenubackground.jpg'});
var win_fav=Ti.UI.createWindow({backgroundImage:'goldmenubackground.jpg'});
var win_morerest=Ti.UI.createWindow({backgroundImage:'goldmenubackground.jpg'});
var tabgroup1=Ti.UI.createTabGroup();
var tab_nearby=Ti.UI.createTab({title:'Near By',window:win});
var tab_zipsearch=Ti.UI.createTab({title:'Zip Search',window:win_zipsearch});
var tab_search=Ti.UI.createTab({title:'Search',window:win_search});
var tab_fav=Ti.UI.createTab({title:'My Favourites',window:win_fav});
var tab_morerest=Ti.UI.createTab({title:'More Restaurants',window:win_morerest});
tabgroup1.addTab(tab_nearby);
tabgroup1.addTab(tab_zipsearch);
tabgroup1.addTab(tab_search);
tabgroup1.addTab(tab_fav);
tabgroup1.addTab(tab_morerest);
tabgroup1.open();
my aim was to create a window of tabgroup
insted it is creating a loop of window creation with tabs in it.
i have to uninstall the app to stop it's loop of creations.
please help
i cant find any error in the code .......
FYI: i created some other sample windows and they are working fine.
you cant take your currentWindow, win and stick it in the TabGroup the way you are.
also would need to see more of the code that is calling this .js file to pinpoint the exact problem; but I think that is the start of your problem

Categories

Resources