Updatestrings of Bootstrap

Source: Internet
Author: User
Updatestrings


Package Io. appium. android. bootstrap. handler; import Io. appium. android. bootstrap. androidcommand; import Io. appium. android. bootstrap. androidcommandresult; import Io. appium. android. bootstrap. commandhandler; import Io. appium. android. bootstrap. logger; import Java. io. datainputstream; import Java. io. file; import Java. io. fileinputstream; import Org. JSON. jsonobject;/*** this handler is used to update the APK strin GS. **/public class updatestrings extends commandhandler {/*** strings. the JSON file stores the strings of the APK. the content in XML is parsed by the appium server and pushed to the device ** @ return */public static Boolean loadstringsjson () {logger. debug ("loading JSON... "); try {final string filepath ="/data/local/tmp/strings. JSON "; final file jsonfile = new file (filepath); // JSON will not exist for apks that are only on device // your case is required The APK path must be specified. If the application on the device is started and the app path is not in case, the JSON file does not exist. // because the node server can't extract the JSON from the APK. if (! Jsonfile. exists () {return false;} final datainputstream datainput = new datainputstream (New fileinputstream (jsonfile); Final byte [] jsonbytes = new byte [(INT) jsonfile. length ()]; datainput. readfully (jsonbytes); // This closes fileinputstream datainput. close (); final string jsonstring = new string (jsonbytes, "UTF-8"); // assign the read information to properties in the find class, use find.apk strings = new jsonobject (jsonstring); log Ger. debug ("JSON Loading complete. ");} catch (final exception e) {logger. error ("error loading JSON:" + E. getmessage (); Return false;} return true;}/** @ Param command the {@ link androidcommand} used for this handler. ** @ return {@ link androidcommandresult} ** @ see Io. appium. android. bootstrap. commandhandler # execute (Io. appium. android. * Bootstrap. androidcommand) * // @ override public androidco Mmandresult execute (final androidcommand command) {If (! Loadstringsjson () {return geterrorresult ("unable to load JSON file and update strings.") ;}return getsuccessresult (true );}}

During appium initialization, if you add an app in your code instead of starting an existing app on your mobile phone, appium will parse the app, extracts strings from the current language environment of the device. the information in the XML file is stored in strings. JSON, and push it to the/data/local/tmp directory of the mobile phone. When you want to obtain the strings used in the application, the mobile phone will read strings in this directory. JSON file and return it to the client.

So the above Code is the process I mentioned above.





Updatestrings of Bootstrap

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.