XDA Facebook+ Facebook, Dailymotion and Youtube Videos Online watch/down - Windows Mobile Development and Hacking General
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Thanks to joe_coolish for XDAFacebook..
i made a script for this app.
now, you can online watch or download video from facebook, dailymotion and youtube with this app.
install XDAFacebook
install TCPMP player(needed)
install CorePlayer(recomended)
that's all
note: if you have non-engilish rom, go to \Windows\ , copy XDAFacebook.lnk and paste to \Windows\Start Menu\Programs, after installation
Code:
defaultbrowser=regread("hkcr", "http\shell\open\command", "default")
tcpmpdir=regread("hklm", "software\apps\TCPMP The Core Pocket Media Player", "installdir")
if(regkeyexists("hklm", "software\apps\TCPMP The Core Pocket Media Player")=false)
message("TCPMP Player Kayit Defterinde bulunamadi. Yuklu degilse yukleyin, Yukluyse Tekrar Yukleyin^NL^TCPMP Install Directory Regkey Not Found. Please Install Or Reinstall", "imbunned")
endif
regwritestring("hkcr", "http\shell\open\command", "default", """".tcpmpdir."\player.exe"" %1")
coredir=regread("hklm", "software\apps\CoreCodec CorePlayer", "installdir")
if(regkeyexists("hklm", "software\apps\CoreCodec CorePlayer")=true and regread("hkcr", "m3ufile\shell\open\command", "default") ne """".coredir."\player.exe"" %1")
regwritestring("hkcr", "m3ufile\shell\open\command", "default", """".coredir."\player.exe"" %1")
endif
player=systempath("programsmenu") \ "TCPMP.lnk"
if(fileexists(systempath("programsmenu") \ "TCPMP.lnk")=false)
message("TCPMP Player Programlar Menusunde Gorunmuyor^NL^TCPMP Player Not Found in Programs Menu", "imbunned")
endif
player2=systempath("programsmenu") \ "CorePlayer.lnk"
dorothy=systempath("programsmenu") \ "Dorothy Browser.lnk"
uzard=systempath("programsmenu") \ "uZardWebP.lnk"
while Procexists XDAFacebook.exe
if(wndactive("Error")=true)
a=screenwidth()
b=screenheight()
a=a/2
b=b/2
setcliptext(windowtext(a, b))
kill "player.exe"
showwaitcursor
call imbunned
endif
sleep 1000
endwhile
if(procexists("XDAFacebook.exe")=false)
regwritestring("hkcr", "http\shell\open\command", "default", defaultbrowser)
endif
sub imbunned
x=cliptext()
if(Find(x, "youtube.com/watch")<>0)
call youtube
hidewaitcursor
if(fileexists(systempath("programsmenu") \ "CorePlayer.lnk")=false)
message("Youtube CorePlayer gerektirir ve CorePlayer Programlar Menusunde Gorunmuyor^NL^For Youtube Rtsp File, please install CorePlayer. It's Not Found in Programs Menu", "imbunned")
else
link=readfile("\m3u.m3u")
link=split(link, "^NL^")
link=link[1]
run(player2, link)
endif
if(question("Videoyu HD olarak indirmek ister misiniz?^NL^Do You Want Download This Video 'HD Quality' ?", "imbunned")=1)
run("iexplore.exe", cliptext())
endif
elseif(Find (x, "dailymotion.com/video")<>0)
call dailymotion
hidewaitcursor
run("\m3u.m3u")
if(question("Videoyu indirmek ister misiniz?^NL^Do You Want Download This Video?", "imbunned")=1)
run("iexplore.exe", link)
endif
elseif(find(x, "facebook.com/video")<>0)
call facebook
hidewaitcursor
run("\m3u.m3u")
if(question("Videoyu indirmek ister misiniz?^NL^Do You Want Download This Video?", "imbunned")=1)
run("iexplore.exe", link)
endif
elseif(find(x, ".")<>0)
hidewaitcursor
x=cliptext()
x=part(x, "http://", 2)
x=part(x, "Unknown", 1)
switch(question("Dorothy Browser ile acmak icin YES, UzardWeb icin NO^NL^For Dorothy press Yes^NL^UzardWeb, Press No", "imbunned", "YesNoCancel"))
case(yes)
Run(dorothy, x)
case(no)
run(uzard, x)
endswitch
endif
endsub
sub dailymotion
x=cliptext()
x=part(x, "http://", 2)
x=part(x, "Unknown", 1)
a=readfile("http://".x)
a=part(a, "sdURL%22%3A%22", 2)
a=part(a, "%22", 1)
a=replace(a, "%5C%2F", "/")
a=replace(a, "%3F", "?")
a=replace(a, "%3A", ":")
link=replace(a, "%3D", "=")
writefile("\m3u.m3u", link)
endsub
sub facebook
x=cliptext()
id=part(x, "v=", 2)
id=part(id, "#", 1)
id=part(id, "&", 1)
flash="http://www.facebook.com/video/video.php?v=".id
link=readfile(flash)
foreach x in split(link, "addVariable", true)
if(find(x, ".mp4")<>0 and find(x, "lowqual")<>0)
x=part(x, "lowqual_src"", """, 2)
x=part(x, """", 1)
x=replace(x, "http\u00253A\u00252F\u00252F", "http://")
x=replace(x, "u00252F", "")
x=replace(x, "\u00253F", "?")
x=replace(x, "\u00253D", "=")
x=replace(x, "\u002526", "&")
x=replace(x, "\", "/")
elseif(find(x, ".mp4")<>0 and find(x, "video_src")<>0)
x=part(x, "video_src"", """, 2)
x=part(x, """", 1)
x=replace(x, "http\u00253A\u00252F\u00252F", "http://")
x=replace(x, "u00252F", "")
x=replace(x, "\u00253F", "?")
x=replace(x, "\u00253D", "=")
x=replace(x, "\u002526", "&")
x=replace(x, "\", "/")
link=x
endif
endforeach
if(link eq "")
call facebook2
else
writefile("\m3u.m3u", link)
endif
endsub
sub facebook2
x=cliptext()
id=part(x, "v=", 2)
id=part(id, "#", 1)
id=part(id, "&", 1)
flash="http://www.flashvideodownloader.org/download2.php?u=http://www.facebook.com/video/video.php?v=".id
link=readfile(flash)
link=part(link, "r2""><a href=", 2)
link=part(link, " title", 1)
link=part(link, """", 2)
link=part(link, """", 1)
link=replace(link, "u00252F", "")
link=replace(link, "\", "/")
link=replace(link, "http/u00253A//", "http://")
if(link eq "")
call facebook
else
writefile("\m3u.m3u", link)
endif
endsub
sub youtube
delete("\m3u.m3u")
x=cliptext()
x=part(x, "http://", 2)
x=part(x, " ", 1)
x=part(x, "Unknown", 1)
x=part(x, "v=", 2)
delete("\m3u.m3u")
a=readfile("http://www.youtube.com/get_video_info?&video_id=".x)
a=replace(a, "%2F", "/")
a=replace(a, "%3F", "?")
a=replace(a, "%3D", "=")
a=replace(a, "%26", "&")
a=replace(a, "%252", "%2")
a=replace(a, "%253", "%3")
a=replace(a, "%C3", "o")
a=replace(a, "%3A", ":")
foreach c in split(a, "http://", true)
if(find(c, "itag=18")>0)
c=part(c, "%7", 1)
c=part(c, "%2C5", 1)
setcliptext(c)
endif
endforeach
b=readfile("http://m.youtube.com/setpref?gl=US&client=mv-google&hl=en&pref=serve_hq&value=on&next=watch?gl=US&client=mv-google&hl=en&rl=yes&v=/".x)
b=readfile("http://m.youtube.com/watch?gl=US&client=mv-google&hl=en&rl=yes&v=".x)
foreach link in split(b, "rtsp://", true)
if(find(link, ".3gp"))
link=part(link, ".3gp", 1)
link="rtsp://".link.".3gp"
writefile("\m3u.m3u", link."^NL^", true)
endif
endforeach
hidewaitcursor
endsub
exit
woowwww
good work. thank you. congrulations.
Thank you Imbunned. What should we do? After installing the program to download video to watch.
this is not working.!
ERROR MESSAGE.
(This application requires a newer version of the Microsoft .NET compact framework than the version installed on this device.)
My device is HTC Touch2 (t3333)
Related
[Q] Last question about database
I have currently developed 90% of my app, and i need help at the last part. I want to thange the default database path to another user spezified path. i get an error when i try this: Code: String myPath = "/data/data/com.android.providers.settings/databases/settings"; SQLiteDatabase myDB = SQLiteDatabase.openDatabase(myPath, null,SQLiteDatabase.OPEN_READWRITE); The Debug monitor shows: Code: FATAL EXCEPTION: main android.database.sqlite.SQLiteException: unable to open database file i hope someone here can help me
It can't open it because it's not there. You need to create the DB in that "settings" subdirectory. Or you can just use adb shell and copy the DB to .../settings.
the database exists, found with root explorer when i want to acces the database with: SQLiteDatabase myDB = set.this.openOrCreateDatabase("/data/data/com.android.providers.settings/databases/settings.db", MODE_PRIVATE, null); it says, unable to open file, that means that the database not exists, but there is one, please, thats the last part, i need help
ilendemli said: Code: String myPath = "/data/data/com.android.providers.settings/databases/settings"; SQLiteDatabase myDB = SQLiteDatabase.openDatabase(myPath, null,SQLiteDatabase.OPEN_READWRITE); Click to expand... Click to collapse Didn't you forget the ".db" at the end of /data/data/com.android.providers.settings/databases/settings ?
tryed with db and without db, the same problem: Code: SQLiteDatabase myDB = set.this.openOrCreateDatabase("/data/data/com.android.providers.settings/databases/settings.db", MODE_PRIVATE, null);
What does the Debug monitor shows when you do openOrCreateDatabase ? (can't be "unable to open database", if it were it would create it)
I am catching the Exception and showing the error as toast message, at the debugger there is this error: Database: sqlite3_open_v2("/data/data/com.android.providers.settings/settings.db", &handle, 6, NULL) failed
According to this link :http://www.sqlite.org/c3ref/open.html, you should be able to execute sqlite3_errmsg to have a description of the error. But I have to admit that I don't know if you can do that easily with the SDK :/ I don't really know how it handles errors in this case (cause "failed" isn't really speaking to me ^^) Edit : Hey, I just spotted something ! You missed your shot in writing the path to settings.db ! You wrote : /data/data/com.android.providers.settings/settings.db It is : /data/data/com.android.providers.settings/databases/settings.db
I tryed it.. annd.... the same error.. if i try: Code: SQLiteDatabase myDB = set.this.openOrCreateDatabase("/data/data/com.android.providers.settings/databases/settings.db", MODE_PRIVATE, null); it should normally create a new database at the dir. when i type /data/data/.file/settings.db there will be created the database, but at com.android.providers.settings/databases/ or all other com.* folders, it haves no permission.. :/
Try to add WRITE_SECURE_SETTINGS permission to your manifest then. Perhaps it will unlock it
Code: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/> alot of permissions xD i will try it €: nope, no permission.
Well, I think I've reached my limit ^^ I'll go with the "If you don't have and can't have the permission to touch it, then don't" and try to find an API that do the things you want. BTW, can you explain what you want to do with this DB ?
i want to change "wifi_http_proxy" and "wifi_http_port"
Are you sure that these fields even exist ? I can find http_proxy, but no wifi_http_proxy nor wifi_http_port :/
which android do you have? 2.1? or 2.2?
2.2, but I'm using the official SDK website as a reference (and Google, obviously ^^)
can you change proxy settings manually? Virtual Device: { "lightbox_close": "Close", "lightbox_next": "Next", "lightbox_previous": "Previous", "lightbox_error": "The requested content cannot be loaded. Please try again later.", "lightbox_start_slideshow": "Start slideshow", "lightbox_stop_slideshow": "Stop slideshow", "lightbox_full_screen": "Full screen", "lightbox_thumbnails": "Thumbnails", "lightbox_download": "Download", "lightbox_share": "Share", "lightbox_zoom": "Zoom", "lightbox_new_window": "New window", "lightbox_toggle_sidebar": "Toggle sidebar" } My Phone:
Yes, I have the same screen as yours (2nd one).
hmm.. have you ever tryed to change the settings? try it to change, and then open the database /data/data/com.android.providers.settings/databases/settings.db -> system and then look for "wifi_http_proxy" and "wifi_http_port"
I'll try it once I get home. I'm at work now, and they locked the possibility to connect something with USB :/ I'll tell you what I'll see.
[Tutorial]How to remove title of the Power Menu
Tools needed : My KIT for SMALI files (using options for each step ) Notepad++( Hexadecimal editor for *.xml ) _______________ Power Menu modded ______________ { "lightbox_close": "Close", "lightbox_next": "Next", "lightbox_previous": "Previous", "lightbox_error": "The requested content cannot be loaded. Please try again later.", "lightbox_start_slideshow": "Start slideshow", "lightbox_stop_slideshow": "Stop slideshow", "lightbox_full_screen": "Full screen", "lightbox_thumbnails": "Thumbnails", "lightbox_download": "Download", "lightbox_share": "Share", "lightbox_zoom": "Zoom", "lightbox_new_window": "New window", "lightbox_toggle_sidebar": "Toggle sidebar" } Open my zip kit ( recomended in a Theming Folder for example with apkmanager and all files you would like to mod ) What you get : Baksmali Baksmali ( executable Jar File ) Command.exe ( Shell file ) Notepad text with the two commands for decompile and compile already made for you ( just copy and paste into command.exe ) Smali Smali ( executable Jar File ) 1.Pull out android.policy.jar ( located in /framework from the rom you are running. 2.Place it in the file where you unzip my Smali kit. Example : C:\SMALI\android.policy.jar 3. You need to decompile android.policy.jar : Open the cmd ready for you in the kit and paste Code: java -jar baksmali.jar -x android.policy.jar -o classout (classout folder can be renamed to whatever you want, doesnt matter until you dont forget to change the name too in the second command) 4. Make the modifications you want for smali files, in this case : Open Global.Actions.smali with Notepad++ located in \\classout\com\android\internal\policy\impl\ 5. CTRL+F to search the line "settitle" Just over it, you should see a line looking like Code: const v2, 0x1040120 change to : Code: const v2, 0x1040017 6. Compile again android.policy.jar : Open the cmd ready for you in the kit and paste Code: java -Xmx512M -jar smali.jar classout -o classes.dex 7. Copy and paste the file classes.dex into android.policy.jar _ you will overwrite the old "classes.dex" 8. Replace your modded android.policy.jar and flash it _ Enjoy your new Power Menu Thanks to Rafalense
thanks a lot ..was looking for this one too ... you my friend are truly awesome
Thread closed at OP request.
[APP] [4.0.3+] App Backup (Simple backup app) [update 7/26]
Hello XDA :victory: I just finished making a simple yet useful backup app for Android 4.0.3+ (Root needed) It can: Make a Nandroid backup of the following partitions: /data, /cache, /android-secure, /sd-ext, /system Copy all user installed APK's into the sdcard Simple, yes, but somewhat useful Screenshot: { "lightbox_close": "Close", "lightbox_next": "Next", "lightbox_previous": "Previous", "lightbox_error": "The requested content cannot be loaded. Please try again later.", "lightbox_start_slideshow": "Start slideshow", "lightbox_stop_slideshow": "Stop slideshow", "lightbox_full_screen": "Full screen", "lightbox_thumbnails": "Thumbnails", "lightbox_download": "Download", "lightbox_share": "Share", "lightbox_zoom": "Zoom", "lightbox_new_window": "New window", "lightbox_toggle_sidebar": "Toggle sidebar" } Change log: 7/26 -Option to make a full Nandroid backup -Changed some GUI To install: 1. Install this APK. 2. copy this file AND this file to system/bin and set permissions as 655, or run this in adb: 1. "adb push xdevilium_onandroid_data_backup system/bin" 2. "adb push xdevilium_onandroid_backup system/bin" 3. "adb shell chmod 655 system/bin/xdevilium_onandroid_data_backup" 4. "adb shell chmod 655 system/bin/xdevilium_onandroid_backup" Credits: The creator of "onandroid" script (sorry, i forgot the username )
I see that you are using an old version of Online Nandroid. I would really appreciate if you could keep it upto date. Btw, great attempt at an app.
ameer1234567890 said: I see that you are using an old version of Online Nandroid. I would really appreciate if you could keep it upto date. Btw, great attempt at an app. Click to expand... Click to collapse I can't, sorry, I lost the source code and I'm working on Newgen and XDA ROM HUB now
Is it similar to the "App2zip"? Two issue, i can download apk file but i can't download other 2 files, i receive a text web page. Eg:- echo "##########################################" echo "XRH Nadroid Data Backup" echo "* This tool backups /data partition." echo "* It is fully compatible with nandroid." echo "* Based on 'onandroid' By Ameer Dawood" echo "##########################################" echo "" # Define constants path="/sdcard/clockworkmod/backup" safety=7 name="none" tz="u" req_power=10 sdcard_temp_mount="/mnt/sdcard4nandroid" logfile=/data/local/tmp/onandroid.log # Logging function mkdir -p /data/local/tmp [ -f $logfile ] && busybox rm $logfile logmsg(){ message="$*" dtime=`busybox date +%T` echo -e "$dtime $message" echo "$dtime $message" >>$logfile if [ "`busybox which log`" != "" ]; then log -p i -t onandroid "$message" fi } # Process arguments if [ $# -gt 0 ]; then if [ $1 == "--help" ]; then # Display usage instructions clear echo "" echo "Usage: xrh_backup_script [OPTIONS] [NAME]" echo "" Click to expand... Click to collapse
android addicts said: Is it similar to the "App2zip"? Two issue, i can download apk file but i can't download other 2 files, i receive a text web page. Eg:- Click to expand... Click to collapse Right click, save page as
I'm having trouble getting this to work. Is there anyway you can all the install steps into the app for me Sent from my SCH-I800 using Tapatalk 2
[MOD/GUIDE] X-Recents
Hey Guys! After a few requests I decided to share my X-Recents mod with you, so that other developers get the ability to add it to their Rom. This is just for Developers building Roms from Source! Also, medium skills on java coding are recommended! What is X-Recents mod? It's a mod improving the stock android recents, to make them more user-friendly and feature-rich. It was already implemented in my X-Bean Rom for i9000 Please note: - you can use this for all ICS/JB Roms and for all devices - just add me to the credits, if you want to use it, and notify me: [email protected] - The swype FC Bug (occurs when swyping over the Button) still exists, to fix it just add try/catch blocks at all points that cause the FC it (use adb/logcat for analysis) - If you like my work and want to support me, the Thanks & the Donate button are always appreciated! Okay, so let's get started: You can find all files in: system/frameworks/base/packages/SystemUI/src/com/android/systemui/recent (in your working directory, or whereever you're SystemUI sourcecode is) At first, we modify the RecentTasksLoader.java: l.260: final int first = 1; to : final int first = 0; This loads the current activity into the recents list.. Only problem: The launcher shall not be shown in the recents list, so we have to make a exeption for it: l.270: if (item != null) { to : if (item != null && item.packageName!="com.cyanogenmod.trebuchet") { // You can add as many exeptions for apps as you want Next point: Adding the Taskmanager button: At first, open RecentsVerticalScrollView.java: Insert this at line 95: Code: private void opentaskmanager() { PackageManager pm = getContext().getPackageManager(); Intent appStartIntent = pm.getLaunchIntentForPackage("your.taskmanager.packagename.here"); if (null != appStartIntent) { getContext().startActivity(appStartIntent); } } Remember to change the "your.taskmanager.packagename.here" to the package name of your taskmanager! Now, wrap a try/catch block around the loop content in line 107: Code: for (int i = 0; i < mLinearLayout.getChildCount(); i++) { try { View v = mLinearLayout.getChildAt(i); addToRecycledViews(v); mAdapter.recycleView(v); } catch (Exception ex) { } } Also add a try here (I can't give you a line, because you inserted something before) : Code: for (int i = 0; i < mAdapter.getCount(); i++) { try { View old = null; And a catch here: Code: calloutLine.setOnTouchListener(noOpListener); mLinearLayout.addView(view); } catch (Exception ex) { } } To add the button, insert this: Code: Button bt_taskmanager = new Button(getContext()); bt_taskmanager.setText("Task Manager"); bt_taskmanager.setWidth(mLinearLayout.getWidth()); bt_taskmanager.setOnClickListener(new OnClickListener() { public void onClick(View v) { opentaskmanager(); } }); mLinearLayout.addView(bt_taskmanager); Between these two lines: setLayoutTransition(transitioner); // Scroll to end after layout. Okay, now we've got the button! At last I want to give you something you can experiment with: Code: private void clearalltasks() { final ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); final List<ActivityManager.RecentTaskInfo> recentTasks = am.getRecentTasks(50, ActivityManager.RECENT_IGNORE_UNAVAILABLE); for (int i = 0; i >= recentTasks.size(); i++) { RecentTaskInfo item = recentTasks.get(i); if (am != null && item!=null) { try { am.removeTask(item.persistentId, ActivityManager.REMOVE_TASK_KILL_PROCESS); } catch (Exception ex) { } try { am.killBackgroundProcesses(item.origActivity.getPackageName()); } catch (Exception ex) { } } } mLinearLayout.removeAllViews(); try { update(); } catch (Exception ex) { ex.printStackTrace(); } } This is my first attempt to add a clear all button.. Do with it what you want, I tried it and it works half-ways.. But not perfectly. I will add some more things later, for example how to add several more Buttons!
Screenshot: { "lightbox_close": "Close", "lightbox_next": "Next", "lightbox_previous": "Previous", "lightbox_error": "The requested content cannot be loaded. Please try again later.", "lightbox_start_slideshow": "Start slideshow", "lightbox_stop_slideshow": "Stop slideshow", "lightbox_full_screen": "Full screen", "lightbox_thumbnails": "Thumbnails", "lightbox_download": "Download", "lightbox_share": "Share", "lightbox_zoom": "Zoom", "lightbox_new_window": "New window", "lightbox_toggle_sidebar": "Toggle sidebar" }
Very good ...
Awesome post!
[Q] empty fields crast my app
Hello everyone, I have start my first app, with this app, can you count your small change. And It works fine. But, the fields must have a number, otherwise will my app cras. Is there a solution to fix this? I mean if the user no number set on a row, that the app see this as a zero? This looks my app: { "lightbox_close": "Close", "lightbox_next": "Next", "lightbox_previous": "Previous", "lightbox_error": "The requested content cannot be loaded. Please try again later.", "lightbox_start_slideshow": "Start slideshow", "lightbox_stop_slideshow": "Stop slideshow", "lightbox_full_screen": "Full screen", "lightbox_thumbnails": "Thumbnails", "lightbox_download": "Download", "lightbox_share": "Share", "lightbox_zoom": "Zoom", "lightbox_new_window": "New window", "lightbox_toggle_sidebar": "Toggle sidebar" } this is the code what i use, it is maby not perfect but I am a beginner. Code: Button btn_optellen = (Button) findViewById(R.id.btn_optellen); btn_optellen.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { double een = Double.valueOf(txt_001.getText().toString()); double twee = Double.valueOf(txt_002.getText().toString()); double total_een = een * 0.01 ; double total_twee = twee * 0.02 ; double totaal = total_een + total_twee; tt_001.setText(String.format("= €%.2f", total_een )); tt_002.setText(String.format("= €%.2f", total_twee )); tt_totaal.setText(String.format("= €%.2f", totaal));
After you write the values to een and twee, you should do a check if they are null. And if that check is true, then set the value to 0. So to be precise: do this check just before the line double total_een = een * 0.01; Click to expand... Click to collapse -------------------- Phone: Nexus 4 OS: rooted Lollipop LRX21T Bootloader: unlocked Recovery: TWRP 2.8.2.0
Thanxs for your answer. I hope I don't ask to muts. But I am ana beginner. Can your show how I must write it?
Ok so i just researched a bit and found out that if the string to parse is invalid, then there is an exception thrown immediately. I thought that just null would be returned, so we need a different approach. But here os how to do it: Code: Button btn_optellen = (Button) findViewById(R.id.btn_optellen); btn_optellen.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //we should initialize the two doubles to 0, so that we can just leave it like this in case of an error double een = 0; double twee = 0; try { een = Double.valueOf(txt_001.getText()); //btw, you dont need to call toString() after getText(). That method already returns a string so doing this would be redundant } catch (Exception e) {} //nothing has to be done here, because the double has already been initialised to be 0 //same here try { twee = Double.valueOf(txt_002.getText()); } catch (Exception e) {} //so now the two doubles are either set to 0 or to the value entered by the user, if it was a correct number double total_een = een * 0.01 ; double total_twee = twee * 0.02 ; double totaal = total_een + total_twee; tt_001.setText(String.format("= €%.2f", total_een )); tt_002.setText(String.format("= €%.2f", total_twee )); tt_totaal.setText(String.format("= €%.2f", totaal)); -------------------- Phone: Nexus 4 OS: rooted Lollipop LRX21T Bootloader: unlocked Recovery: TWRP 2.8.2.0
Very muth thanx, I am going try it out.