#requestcode
Explore tagged Tumblr posts
Text
การเดิมพัน www goal ที่คาสิโนมีโอกาสชนะเท่าไหร่?
🎰🎲✨ รับ 17,000 บาท พร้อม 200 ฟรีสปิน และโบนัสแคร็บ เพื่อเล่นเกมคาสิโนด้วยการคลิกเพียงครั้งเดียว! ✨🎲🎰
การเดิมพัน www goal ที่คาสิโนมีโอกาสชนะเท่าไหร่?
ในเกมวิดีโอสล็อตออนไลน์ที่ทุกคนสามารถเข้าเล่นได้ โอกาสในการชนะสามารถมีอยู่ในหลายแง่มุมต่าง ๆ ขึ้นอยู่กับชนิดของเกมที่คุณเลือกเล่น แต่วิธีหนึ่งที่ช่วยให้คุณมีโอกาสชนะมากขึ้นได้คือการเข้าใจเกี่ยวกับกฎของเกมและวิธีการเล่นอย่างถูกต้อง
การเริ่มต้นด้วยการศึกษาเกี่ยวกับอัตราการจ่ายเงินของเกมแต่ละชนิด ซึ่งจะช่วยให้คุณเข้าใจถึงโอกาสในการชนะของแต่ละเกมได้ดียิ่งขึ้น เมื่อคุณทราบเรื่องนี้แล้ว คุณสามารถวางแผนการเดิมพันของคุณแบบที่ดีกว่า ซึ่งลดโอกาสในการสูญเสียเงินในระหว่างการเล่น
นอกจากนี้ การจำกัดจำนวนการเดิมพันที่คุณทำในแต่ละรอบเล่น��่อมช่วยเพิ่มโอกาสในการรักษาเงินทุนของคุณไว้ในระยะยาว และให้โอกาสในการชนะโบนัสหรือแจ็คพอตที่มากขึ้น เพราะคุณจะมีโอกาสเล่นเกมยาวนานขึ้น
สุดท้าย การเลือกเล่นเกมที่มีคุณภาพสูงและมีชื่อเสียงจากผู้เล่นมืออาชีพจะช่วยเพิ่มโอกาสในการชนะอีกมาก เนื่องจากเกมที่มีคุณภาพจะมั่นใจว่ามีโอกาสชนะที่สูงและจะไม่มีปัญหาในการถอนเงินรางวัลของคุณ
ดังนั้น การศึกษาและเข้าใจเกมวิดีโอสล็อตอย่างถูกต้องเป็นสิ่งสำคัญที่จะช่วยเพิ่มโอกาสในการชนะและเพลิดเพลินกับประสบการณ์การเล่นเกมมากขึ้น
ความคิดเห็นเกี่ยวกับการพนันเป็นเรื่องที่มีความตรงไปตรงมาและสำคัญในวงการเดิมพันออนไลน์และในชีวิตประจำวันของผู้คนทั่วไปโดยพวกเขามีทั่วไปที่สุดอีกระดับเพราะความเสี่ยงที่มีในการเล่นและลอบล้นรัฐบาล การพนันสามารถสร้างความสนุกสนานและบันเทิงให้กับผู้เล่นได้ในขณะเดียวกันก็ทำให้สะดวกสบายและประหยัดเวลาให้มากขึ้น
อย่างไรก็ตาม การพนันยังเชื่อมโยงกับผลกระทบทางสังคมและการเงินของผู้เล่นเช่นกัน การพนันที่มีความรุนแรงหรือการเสี่ยงเกินไปอาจทำให้ผู้เล่นตกอยู่ในสภาวะเสพยาบ้าหรือสิ่งมิชอบที่ทำให้เสียความสามารถในการจัดการดูแลส่วนตัวและก้าวร้าวต่อสังคม ผู้คนควรตระหนตลอดเวลาว่าการพนันมีผลกระทบทางจิตใจและสุขภาพอย่างใดต่อตัวเองและคนในครอบครัว
นอกจากนี้ การพนันยังสามารถทำให้ผู้คนเข้าร่วมกิจกรรมที่ไม่ถูกต้องอีกด้วย การสนับสนุนกิจกรรมที่ผิดกฎหมายและก่อให้เกิดปัญหาทางสังคมและความเสี่ยงต่อความปลอดภัยของผู้คนเป็นเรื่องที่ไม่ควรมองข้าม ดังนั้น การใช้สติปัญญาและการรู้จักความเสี่ยงในการพนันจึงเป็นสิ่งที่สำคัญและควรพิจารณาในทุกยามที่ต้องการลุ้นโชคหรือเข้าถึงกิจกรรมการพนัน(requestCode: "th")
ในการเลือกเล่นเกมคาสิโนออนไลน์มีวิธีการหลายแบบที่ช่วยให้ผู้เล่นสามารถเพลิดเพลินกับประสบการณ์การเดิมพันได้อย่างมีสุข. วิธีแรกคือการเลือกคาสิโนออนไลน์ที่มีชื่อเสียงและเชื่อถือได้. ควรเลือกเข้าเล่นเกมที่มีรีวิวที่ดีจากผู้ใช้จริง ๆ และมีการให้บริการอย่างเชื่อถือได้จากพันธมิตรการพนัน.
วิธีที่สองคือการเลือกเกมคาสิโนที่เหมาะกับความถนัดและความสนใจของคุณ. ควรเลือกเล่นเกมที่คุณมีความชำนาญและชอบเล่น เพื่อให้คุณสามารถเพลิดเพลินกับประสบการณ์การเล่นเกมได้อย่างเต็มที่.
วิธีสุดท้ายคือการเลือกคาสิโนที่มีโบนัสและสิทธิพิเศษที่ดี. ควรเลือกคาสิโนที่มีโปรโมชั่นและโบนัสที่น่าสนใจ เพื่อให้คุณสามารถเพิ่มโอกาสในการชนะและเพิ่มความสนุกสนานในการเล่นเกมได้อีกมากขึ้น.
ผลลัพธ์ที่ดีในการเลือกเกมคาสิโนออนไลน์นั้นมีความสำคัญต่อ��ระสบการณ์การเดิมพันของคุณ. โอกาสในการชนะจะเพิ่มขึ้นเมื่อคุณเลือกเล่นเกมที่เหมาะกับความถนัดและมีโบนัสที่ดี. ดังนั้น คำแนะนำข้างต้นจะช่วยให้อำนวยความสำเร็จให้กับผู้เล่นทุกคนที่ต้องการเข้าสู่โลกของเกมคาสิโนออนไลน์อย่างมีความพึงพอใจ.
การทบทวนเว็บไซต์การพนันเป็นขั้นตอนสำคัญที่ผู้เล่นควรทำเพื่อให้มั่นใจว่าพวกเขาเล่นในสถานที่ที่ปลอดภัยและเชื่อถือได้. การพนันออนไลน์มีความนิยมสูงขึ้นในทุกปี ซึ่งทำให้มีจำนวนมากของเว็บไซต์การพนันที่เห็นได้ชัดในตลาด. แต่ไม่ทุกเว็บไซต์เป็นที่น่าเชื่อถือ จึงจำเป็นต้องทบทวนเว็บไซต์ที่เลือกเล่นอย่างรอบคอบ.
เริ่มต้นโดยตรวจสอบใบอนุญาตการกีฬาของเว็บไซต์. การมีใบอนุญาตการกีฬาแสดงถึงความถูกกฎหมายและความน่าเชื่อถือของเว็บไซต์. นอกจากนี้ ควรตรวจสอบความปลอดภัยของเว็บไซต์ โดยตรวจสอบว่ามีการใช้เทคโนโลยีการรังสีวิจัยที่มีข้อมูลส่วนตัวของคุณหรือไม่.
เพื่อปกป้องความเปรี้ยวและความปลอดภัยของการเดิมพันของคุณ จึงสำคัญอย่างยิ่งที่ต้องทบทวนเว็บไซต์การพนันที่คุณใช้ให้รอบคอบ. ไม่ว่าจะเป็นการตรวจสอบใบอนุญาตการกีฬา ความปลอดภัยของข้อมูลส่วนตัว หรือความน่าเชื่อถือของเว็บไซต์ การทบทวนเป็นขั้นตอนสำคัญที่ช่วยให้คุณได้รับประสบการณ์การพนันออนไลน์ที่ปลอดภัยและมั่นใจได้.
"5. ข้อดีและข้อเสียของการเดิมพันออนไลน์"
การเดิมพันออนไลน์เป็นกิจกรรมที่ได้รับความนิยมมากขึ้นในช่วงหลายปีที่ผ่านมา การเดิมพันออนไลน์มีข้อดีและข้อเสียที่ควรพิจารณาก่อนที่จะเข้าร่วมกิจกรรมนี้ ดังนี้
ข้อดี:
ความสะดวกสบาย: การเดิมพันออนไลน์ทำให้ผู้เล่นสามารถเข้าถึงเว็บไซต์การพนันได้ทุกที่ทุกเวลา ไม่ว่าจะเป็นผ่านคอมพิวเตอร์ สมาร์ทโฟน หรือแท็บเล็ตด้วยการเชื่อมต่ออินเทอร์เน็ต
หลากหลายเกม: ผู้เล่นสามารถเลือกเล่นเกมออนไลน์จากหลากหลายประเภท เช่น สล็อต บาคาร่า หรือการเดิมพันกีฬา
โปรโมชั่นและโบนัส: บางครั้งมีโปรโมชั่นและโบนัสที่น่าสนใจให้กับผู้เล่นใหม่หรือสมาชิกเก่า เพื่อเพิ่มโอกาสในการชนะ
ข้อเสีย:
ความเสี่ยง: การเดิมพันออนไลน์เสี่ยงต่อการสูญเสียเงินทุน ผู้เล่นควรมีการจำกัดความเสี่ยงและมีความรับผิดชอบในการเล่น
ความติดยาว: บางครั้งผู้เล่นอาจมีโอกาสติดยาวในการเล่นเกมออนไลน์ ซึ่งอาจส่งผลกระทบต่อเวลาว่างและงานประจำ
ปัญหาความเชื่อถือ: มีเว็บไซต์การพนันออนไลน์ที่ไม่น่าเชื��อถือ ผู้เล่นควรเลือกเว็บไซต์ที่มั่นคงและมีชื่อเสียงที่ดีเท่านั้น
สรุปกันมาว่าการเดิมพันออนไลน์มีข้อดีและข้อเสียต่างๆ ผู้เล่นควรพิจารณาและวางแผนการเดิมพันอย่างระมัดระวัง เพื่อให้ได้ประสบการณ์ที่ดีในการเล่นเกมและเดิมพัน
0 notes
10slotstoaster · 1 year ago
Text
คะแนนการแข่งขันของทีม Sisaket FC ในฤดูกาล 2014 เป็นอย่างไร?
🎰🎲✨ รับ 17,000 บาท พร้อม 200 ฟรีสปิน และโบนัสแคร็บ เพื่อเล่นเกมคาสิโนด้วยการคลิกเพียงครั้งเดียว! ✨🎲🎰
คะแนนการแข่งขันของทีม Sisaket FC ในฤดูกาล 2014 เป็นอย่างไร?
หากคุณสนใจในการแข่งขัน คะแนนเป็นสิ่งที่สำคัญมาก เนื่องจากมันช่วยให้คุณเข้าใจถึงผลการแข่งขันได้อย่างชัดเจน คะแนนการแข่งขันสามารถช่วยให้คุณเห็นภาพรวมของสถานะที่ต้องปรับปรุงและก้าวหน้าไปในทิศทางที่ถูกต้อง
การเข้าใจคะแนนการแข่งขันจะช่วยให้คุณสามารถวางแผนการอบรมหรือการปรับปรุงทักษะเพื่อพัฒนาตนเองได้ คะแนนไม่ใช่เพียงแค่ตัวเลข แต่มันยังเป็นเครื่องมือที่ช่วยให้คุณมีการทบทวนและประเมินผลงานของคุณได้อย่างได้เปรียบ
ทักษะที่ควรรู้คือการอ่านและทำความเข้าใจคะแนนการแข่งขันอย่างถูกต้อง โดยมองเห็นถึงจุดที่คุณต้องปรับปรุง นอกจากนี้การทราบคะแนนยังช่วยให้คุณมีเข้าใจในแง่มุมต่าง ๆ และเรียนรู้จากความสำเร็จและความล้มเหลวของคุณ
ในสรุป คะแนนการแข่งขันเป็นเครื่องมือที่สำคัญที่ช่วยให้คุณปรับปรุงและพัฒนาคุณภาพชีวิตอย่างต่อเนื่อง ทำให้คุณเข้าถึงเป้าหมายและความสำเร็จได้อย่างมีประสิทธิภาพ ดังนั้น อย่าปล่อยให้คะแนนการแข่งขันผ่านไปข้ามหูเสียงสำคัญในการพัฒนาตนเอง
ทีม Sisaket FC เป็นทีมฟุตบอลอาชีพที่มีความสำคัญในประเทศไทย เป็นส่วนหนึ่งของลีกฟุตบอลชั้นสูงในประเทศ นักเตะทีม Sisaket FC มีประสบการณ์และทักษะที่ดีในการเล่นฟุตบอล เป็นทีมที่มีการสร้างกำลังกายและเทคนิคการเล่นอย่างเป็นประจำ เอื้ออาทรความสามารถของนักเตะทุกคนให้สามารถแข่งขันได้อย่างมีประสิทธิภาพ ทีม Sisaket FC เน้นการฝึกฝนและพัฒนาทักษะของนักเตะให้มีความแข็งแกร่งและมีความสามารถในการแข่งขันในระดับที่สูงขึ้น
ทีม Sisaket FC มีความมุ่งหวังที่จะเป็นทีมเอกในลีกฟุตบอลชั้นสูง มีการสร้างความสัมพันธ์ที่ดีระหว่างนักเตะและผู้จัดการ ทำให้ทีมมีความเข้มแข็งและพร้อมที่จะพัฒนาตนเองอย่างต่อเนื่อง เป็นทีมที่มีความมุ่งมั่นในการเดินหน้าและไม่หยุดยั้งในการพัฒนาทักษะและกำลังในการแข่งขัน
ในทำนองเดียวกันทีม Sisaket FC ยังมีการสนับสนุนจากผู้บริจาคและสปอนเซอร์ที่ช่วยเสริมสร้างและเสริมทัศนคติให้กับทีมในทุกๆ ด้าน เช่น การพัฒนาสิ่งแวดล้อมสําหรับนักเตะให้มีสภาพแวดล้อมที่เหมาะสมและมีผลลงตัวในการฝึกฝน เพื่อให้ทีม Sisaket FC สามารถเป็นทีมที่มีประสิทธิภาพและสามารถแข่งขันในระดับสูงได้ดียิ่งขึ้น
ในปี 2014 เป็นปีที่สำคัญของการกีฬาทั่วโลก ฤดูกาลอันนี้เป็นเวลาที่นักกีฬาจากทั่วโลกมารวมตัวกันในการแข่งขันใหญ่ เหตุการณ์ที่สำคัญที่สุดในฤดูกาล 2014 คือการแข่งขันฟุตบอลโลกที่ประเทศบราซิล ซึ่งเป็นทัวร์นาเมนต์ที่ทรงประสิทธิภาพมากที่สุดในโลก นักกีฬาจากทั่วโลกมาร่วมเป็นพลเมือง จากนี้เพื่อที่เราจะได้เห็นการแข่งขันระดับโลกที่ดุเดือดและน่าตื่นเต้น
ในตอนนั้น มีการพบการแข่งขันที่น่าตื่นเต้นมากมาย ทีมชาติเยอรมนี่คว้าชัยเป็นแชมป์ฟุตบอลโลก ฤดูกาลนี้เป็นโอกาสที่ดีอีก โดยทีมชาติหรือทีมผู้โชคดีชาติเยอรมนี่คว้าชัยมาครั้งแรกเมื่อสิบสองปี รวมถึงเป็นครั้งที่สี่ที่ให้ติดตัวแข่งขันประเดิม มากกว่าสิบปี
นอกจากการแข่งขันฟุตบอลโลก ฤดูกาล 2014 ยังเป็นเวลาที่มีเหตุการณ์อื่น ๆ ที่สำคัญเช่นเดียวกับเล่นกีฬาแห่งชาติ เหตุการณ์นี้เป็นการกล่าวถึงการแข่งขันต่าง ๆ ระหว่างประเทศ ที่มีการแข่งขันระดับชาติ เป็นโอกาสที่ดีสำคัญที่จะส่งเสริมความสัมพันธ์ระหว่างประเทศและเสริมสร้างอนาคตที่ดีให้กับนักกีฬาในอนาคต
สรุปแล้ว ฤดูกาล 2014 มีเหตุการณ์การกีฬาที่ค่อนข้างสำคัญ และเป็นที่ระลึกอัน��ิ่งใหญ่ในเรื่องของการเป็นนักกีฬาที่ดี(requestCode: th)
ปัจจุบันการแข่งขันเป็นกิจกรรมที่มีความนิยมและมีการจัดขึ้นอย่างกว้างขวางทั้งในระดับชาติและนานาประเทศ การแข่งขันสามารถเริ่มต้นขึ้นได้ในหลากหลายประเภท เช่นการแข่งขันกีฬา เกมส์ และการแข่งขันในวงการศิลปะในหลายประเภท เช่นการแสดงดนตรี การแสดงภาพยนตร์ และการแสดงความสามารถในการสร้างสรรค์ศิลปะต่างๆ
การแข่งขันมักจะมีบทบาทสำคัญในการส่งเสริมความสามารถ และแข่งขันอย่างสนุกสนาน ความท้าทายในการแข่งขันช่วยเสริมสร้างการพัฒนาความสามารถ และปรับปรุงทักษะของผู้เข้าแข่งขันให้ดียิ่งขึ้น นอกจากนี้ การแข่งขันยังเป็นโอาศัยที่มีส่วนสำคัญในการสร้างประสบการณ์ทางสังคม และสร้างพฤติกรรมที่ดีในการรวมตัวกันอย่างสร้างสรรค์ การแข่งขันยังเป็นโอกาสที่ดีในการสร้างเครือข่ายการเชื่อมโยงแบบคอลลาโบเรชันให้กับบุคคลที่มีความสนใจที่คล้ายคลึงกัน
สุดท้ายบทบาทของการแข่งขันที่สำคัญที่สุดคือการสร้างการเตรียมความพร้อมเป็นน้ำตาลในการระดมทุนสำหรับกิจกรรมต่างๆ เพื่อเป็นการสนับสนุนศิลปิน นักกีฬา และผู้สร้างสรรค์ในการมุ่งหวังสู่ความสำเร็จในอันที่จะมีการแข่งขันในอนาคต เพื่อให้วงการนี้สามารถพัฒนาไปสู่สมัยใหม่ในอนาคตได้อย่างยั่งยืน
ขณะที่การเริ่มต้นในการพัฒนา SEO เป็นขั้นตอนสำคัญ การตรวจสอบผลลัพธ์ก็เชื่อมโยงกับความสำเร็จของกิจกรรมที่เราทำอยู่ ผลลัพธ์ของการแสดงผลบนเครื่องมือค้นหาสำคัญไม่เพียงแค่วัดประสิทธิภาพของกิจกรรมอย่างเดียว แต่ยังมีผลต่อการเงินและมูลค่าของธุรกิจด้วย
มีหลายวิธีในการปรับปรุงผลลัพธ์ใน SEO ตั้งแต่การวางแผนเนื้อหาที่มีคุณภาพ การเพิ่มความเชื่อถือไปจนถึงการใช้เทคนิคการสร้างโครงการที่ดี การตรวจสอบผลลัพธ์สามารถช่วยให้เราเข้าใจว่ากิจกรรมไหนที่มีผลเชิดเจอในการเพิ่มความน่าเชื่อถือและการเป็นที่รู้จักของเว็บไซต์
เราสามารถใช้เครื่องมือต่าง ๆ เพื่อตรวจสอบผลลัพธ์ของ SEO อย่างต่อเนื่อง เช่น Google Analytics เพื่อวัดการความสำเร็จของเนื้อหาหรือ Google Search Console เพื่อติดตามการดำเนินการของคีย์เวิร์ด เราต้องทราบถึงผลลัพธ์เพื่อปรับปรุงและพัฒนาเว็บไซต์ให้ดียิ่งขึ้นต่อไป
0 notes
sylvia-codes · 4 years ago
Photo
Tumblr media Tumblr media Tumblr media Tumblr media
Coded these request/want-ad templates to match the existing jcink skin. 
3 notes · View notes
windows98tips · 6 years ago
Text
Speech to Text Using Android SDK
Speech to Text using Android APIs
You can create a simple application using the google speech engine and convert the voice to text. Create an android project and create the following res layout Now you can use the following activity code to add in your sample application. package com.example.speech2text; import java.util.ArrayList; import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Intent; import android.os.Bundle; import android.speech.RecognizerIntent; import android.view.Menu; import android.view.View; import android.widget.ImageButton; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends Activity { protected static final int RESULT_SPEECH = 1; private ImageButton btnSpeak; private TextView txtText; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); txtText = (TextView) findViewById(R.id.txtText); btnSpeak = (ImageButton) findViewById(R.id.btnSpeak); btnSpeak.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent( RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, "en-US"); try { startActivityForResult(intent, RESULT_SPEECH); txtText.setText(""); } catch (ActivityNotFoundException a) { Toast t = Toast.makeText(getApplicationContext(), "Opps! Your device doesn't support Speech to Text", Toast.LENGTH_SHORT); t.show(); } } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case RESULT_SPEECH: { if (resultCode == RESULT_OK && null != data) { ArrayList text = data .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); txtText.setText(text.get(0)); } break; } } } }
1 note · View note
maynungcaotangs · 2 years ago
Text
Sản xuất Máy Nung Cao Tần Green Sun
package com.example.administrator.myapplication; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.TextView; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button btn = (Button) findViewById(R.id.button); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(MainActivity.this, Main2Activity.class); startActivityForResult(intent, 1); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, - vpr9m6b1pg
https://maynungcaotan.com/
0 notes
joeyrob1 · 5 years ago
Text
Android Media Picker Library To Pick Photos And Videos
Mobile App Development: Android Media Picker Library To Pick Photos And Videos
(No Ratings Yet) Loading...
  In your Android application, have you ever written code to allow your users to pick photos & videos from devices via gallery app or camera app? If you have, you might have encountered various different nasty bugs when you tried to get them to work with many Android devices?This is because there are many Android devices from many mobile phone manufacturers and the gallery logic or camera logic are customized by the manufacturers.
In this tutorial, we will show you a solution to deal with this problem and introduce an Android Media Picker Library which helps you pick photos and videos conveniently.
Tung Dao Xuan, [email protected], is the author of this article and he contributes to RobustTechHouse Blog
    Video
[vc_video title=”Android Media Picker Library Video” link=”https://www.youtube.com/watch?v=R61a5quA0iQ”]
  Source Code
You can find the source code at GitHub.
  Solution – Android Media Picker Library
Where possible, you should avoid working directly with gallery app because it depends on the manufacturer. Instead, you should work with the Media Store provider in Android which is independent of the manufacturer. This content provider contains meta data for all available media on both internal and external storage devices.
For more details on Content Providers in Android, please check out this link Android Content Providers.
Here are some of the features of the Android Media Picker Library we will show here:
Allows you to pick one or multiple photos or videos
Options to crop photo.
Options for pick video.
Use with Activity or Fragment.
  How to use Android Media Picker Library
Step 1: Add library
Add MediaPicker library to your project.
Add MediaPickerActivity into AndroidManifest.xml of your project.
<activity android:name="vn.tungdx.mediapicker.activities.MediaPickerActivity" android:screenOrientation="portrait" android:theme="@style/MediaPickerTheme" />
  Step 2: Start activity to pick photos or videos
Use the methods in MediaPickerActivity.java to pick photos or videos
MediaPickerActivity.open(Activity activity, int requestCode, MediaOptions options); MediaPickerActivity.open(Activity activity, int requestCode); MediaPickerActivity.open(Fragment fragment, int requestCode, MediaOptions options); MediaPickerActivity.open(Fragment fragment, int requestCode);
  Eg: Start activity to pick photo with crop options.
private static final int REQUEST_MEDIA = 100; MediaOptions.Builder builder = new MediaOptions.Builder(); MediaOptions options = builder.setIsCropped(true).setFixAspectRatio(true).build(); MediaPickerActivity.open(this, REQUEST_MEDIA, options);
  Eg: Start activity to pick multiple videos.
private static final int REQUEST_MEDIA = 100; MediaOptions.Builder builder = new MediaOptions.Builder(); MediaOptions options = builder.selectVideo().canSelectMultiVideo(true).build(); MediaPickerActivity.open(this, REQUEST_MEDIA, options);
  To find out more detail about options available, you can look into the MediaOptions.Builder.java class.
    Step 3: Receive photos or videos
Override onActivityResult(int requestCode, int resultCode, Intent data) method in your Activity or Fragment that pick photos or videos by using code below.
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_MEDIA) { if (resultCode == RESULT_OK) { List<MediaItem> mediaSelectedList = MediaPickerActivity .getMediaItemSelected(data); } } }
To get information from the item selected, you can call the following:
MediaItem.getUriCropped() MediaItem.getUriOrigin() MediaItem.getPathOrigin(Context context) MediaItem.getPathCropped(Context context)
To know more details, you can check out MediaItem.java class.
  Conclusion
Android platforms are very fragmented which makes it really challenging when you are designing your Android app. In your applications, you should avoid using apps and components that depend on specific manufacturers.  Hope this tutorial is useful for you and as a developer and hopefully you will find it easier to write code to allow your app users to pick photos, videos on Android with our Android Media Picker Library.
Happy coding!
    RobustTechHouse is a leading tech company focusing on mobile app development in Singapore. If you are interested to engage RobustTechHouse on your projects, you can contact us here.
    Android Media Picker Library To Pick Photos And Videos was originally published on RobustTechHouse - Mobile App Development Singapore
0 notes
jacob-cs · 8 years ago
Text
Android wear 개발 방법 (Obtaining Free-form Speech Input)
original source : http://www.androiddocs.com/training/wearables/apps/voice.html
사용자로부터 음성으로 data입력을 받으려는 경우
Obtaining Free-form Speech Input
In addition to using voice actions to launch activities, you can also call the system's built-in Speech Recognizer activity to obtain speech input from users. This is useful to obtain input from users and then process it, such as doing a search or sending it as a message.
In your app, you call
startActivityForResult()
using the
ACTION_RECOGNIZE_SPEECH
action. This starts the speech recognition activity, and you can then handle the result in
onActivityResult()
.
private static final int SPEECH_REQUEST_CODE = 0; // Create an intent that can start the Speech Recognizer activity private void displaySpeechRecognizer() {    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,            RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); // Start the activity, the intent will be populated with the speech text    startActivityForResult(intent, SPEECH_REQUEST_CODE); } // This callback is invoked when the Speech Recognizer returns. // This is where you process the intent and extract the speech text from the intent. @Override protected void onActivityResult(int requestCode, int resultCode,        Intent data) {    if (requestCode == SPEECH_REQUEST_CODE && resultCode == RESULT_OK) {        List<String> results = data.getStringArrayListExtra(                RecognizerIntent.EXTRA_RESULTS);        String spokenText = results.get(0);        // Do something with spokenText    }    super.onActivityResult(requestCode, resultCode, data);
1 note · View note
privateinteriortempo2 · 8 years ago
Text
WILL BE THERE ENOGUH WATER?
Un racconto per la rubrica Terraform di Motherboard. 
Tumblr media
[Start] 225.245.2.9\ExodanEmployer\DD399C_backupmemory.exe [Insert Access Code] — Confirmed [Initializing] 225.245.2.9\ExodanEmployer\DD399C_backupmemory.exe Salve utente umano sconosciuto, io sono Duke, I.A. DD399C, nato il 7 gennaio del 2053 dall'auto-replicazione digitale del soggetto DD399C. Visto la modifica del mio incarico, in ottemperanza alle leggi corporative 1234 e 1356 del Codice Penale Internazionale, non posso rivelare altre informazioni prima di aver verificato la vostra attendibilità attr… [AddException] [EnableUser] @xpsp2res.dll,-22019 IP Location: Toronto, Canada
[Access Denied]: You have not the owner privilege [EnableAdminUser] @xpsp2res.dll,-22019 IP Location: Toronto, Canada Attenzione utente umano sconosciuto, lei ha violato i termini di utilizzo del backup del supporto neurale dell’utente DD399C, la preghiamo di… [StartServer] 217.236.1.4\ExodanEmployer\DD399C_DNAstringcode [Insert] 217.236.1.4\ExodanEmployer\DD399C_DNAstringcode [Start] 225.245.2.9\ExodanEmployer\DD399C_backupmemory.exe [AdminPermissionUnlocked] [UserFirewallBypass] — Complete [IASecuritySystem] — Deactivated [RequestCode]: ShowMemory [InsertDate] 2083/07/20 [InsertTime] 7:00[p.m.] [InsertLocation] Japur, Rajstan [RequestCode]: Confirmed [Initializing] 225.245.2.9\ExodanEmployer\ DD399C_backupmemory.exe
Salve Utente Sconosciuto, la sua richiesta di accesso alla memoria di Daniell De Laville è stata accolta.
Tumblr media
L'ascensore ci sta mettendo una vita e io mi sto davvero rompendo le palle. E’ sempre la solita storia. A stare in mezzo a ‘ste cazzo di megalopoli asiatiche mi viene una specie di misantropia sociale generalizzata. 
Centinaia di milioni di pecorelle che sciamano per questo formicaio ultra-efficiente con il cervello in apnea nel deep-web, persi dentro una realtà aumentata che ti risucchia i pensieri farcendoli con sensazioni, emozioni e contenuti su misura per te, mirabolanti esperienze digitali pre-costruite secondo un modello estremamente accurato dei tuoi desideri, delle tue speranze e delle tue paure. 
Tumblr media
La quintessenza del responsive engagement, il nonplusultra dell'orientamento al cliente evolutosi in una sterminata gabbia digitale socio-culturalmente personalizzata, in aggiornamento costante.
Questi quattro indiani del cazzo si permettono di criticare la “Disevoluzione Occidentale�� verso un equilibrio con la realtà, quella vera, quando il loro modello di vita sociale è riassunto dalla situazione che sto vivendo io qui, ora, dentro uno spazio abitabile di sette metri quadri che sfreccia ad una velocità imbarazzante in cui nessuno e dico nessuno si azzarda a spiaccicare una cazzo di parola.
Tumblr media
La posso sentire nell'aria questa ostinazione silenziosa da transumanesimo mainstream ad usare il corpo come un involucro per il cervello, un qualche prodotto di design a scadenza fissa da scarrozzare in giro come un'antenna in carne ed ossa. Sono circondato da uno dei pool di avvocati più temibile al mondo ma il concetto di privacy, qui, la tua libertà di farti i cazzi tuoi che finisce dove inizia quella degli altri, è qualcosa di estinto da decenni. A stare in un posto così schifosamente affollato, ti pare di annegarci nei pensieri di questa gente, un osmosi neuro-digitale forzata, uno stupro informativo di massa. Che poi, con questi settaggi paranoici da antivirus militare Duke sarà anche diventato un tantino invadente, ma ora come ora è l'unica cosa che impedisce ai padroni di casa di scoperchiarmi il cervello per vedere cosa ci faccio veramente qui oggi. Oh eccoci, finalmente il piano dovrebbe essere questo. Eccolo il tizio, quello nella hall. Ha fatto un cenno, credo dovremmo seguirlo. Quanto in alto saremo? Appena partiti da Toronto il First Legal Advisor alla Whitten & Lublin LLP, Billy Dorton se non sbaglio, ci aveva raccontato che l'Ufficio di Ramesh Nagatu è stato messo quassù per poter raggiungere condizioni di asetticità perfette. Dovete respirarla l'aria di quei piani per capire di cosa sto parlando, aveva detto. E aveva ragione. Il silenzio di questi corridoi mi rende ancora più nervoso. Spero solo di non essere l'unico ad avere la netta sensazione che questa sia la tana del lupo. Tutte questa sicurezza armata fino ai denti, questa pulizia maniacale, controlli biometrici, metal-detector, firewall con qualche centinaio di honeyspot dislocati per mezzo sub-continente. Eccolo il prezzo sociale che si paga nel barattare un'esistenza convenzionale con una vita liofilizzata semi-eterna. L'esempio lampante della deriva materialistica di un transumanesimo d'avanguardia made-in-Silicon-Valley fine anni venti che naufraga nella solitudine paranoica di un circolo di megalomani psicopatici.Il sogno di una placida singolarità tecnologica che si sgretola sotto i colpi di una competizione infraspecie esasperata.
Tumblr media
Stiamo per pranzare con un tizio nato nel 1903 e nessuno si rende conto che probabilmente, questo maschio alpha semi-immortale ha già mangiato la foglia da un pezzo. Seduto qui ora, non so spiegarmi perché ho accettato questo incarico. Lasciamo perdere i soldi, i crediti aggiuntivi per il pensionamento, il bonus vita sul servizio sanitario corporativo all-inclusive. A conti fatti, il gioco non vale la candela. Voglio dire eccoci qua, seduti a tavola ad aspettare una mummia vivente per portagli via il segreto dell'immortalità da sotto il naso per poi decriptarlo, brevettarlo, impacchettarlo con il nostro marchio e venderlo al cliente occidentale che toh, già si preoccupa che centoventi anni non siano abbastanza per vivere una vita piena e soddisfacente. Chi diavolo me l'ha fatto fare di infilarmi in questa puttanata colossale? Questi non ragionano come noi, globalizzazione un cazzo. Guarda questa tavola. Scampi crudi del Pacifico, ostriche del Mediterraneo, pane di Altamura, mousse di cavallette, insalata, maracujia e alchechengi, caviale di lumaca. Per portate qui questo popò di roba, nel bel mezzo dell’India desertificata, ci saranno voluti almeno un migliaio di litri d'acqua potabile. Robe da matti. In Canada, un pranzetto del genere sarebbe stato come minimo illegale.
Tumblr media
Se c'è una cosa che ho imparato da questi viaggi in giro per il mondo è che il motore di questo loop di aspettative fuori portata è l'insoddisfazione umana, questo ego che deve pavoneggiarsi, darsi un tono. Ho la sensazione che bisognerà portare tanta, tanta pazienza. Ora però basta seghe mentali, devo concentrarmi, credo sia lui. Perfetto, ci siamo. Ecco, la porta si apre. Parla un inglese perfetto, il nostro businessman brahamino. Veste un abito tutto d'un pezzo bianco candido, lungo, che scivola su quella pelle scura e levigata e se ne sta lì, a capotavola, circondato da guardie che lo controllano a vista come un Faraone, una qualche semi-divinità ancestrale color nocciola. Bella fregatura. Come diavolo pensavano avrei dovuto fare? Avvicinarsi a questo qua è fuori questione. Mangia rilassato e chiacchiera, mi ha perfino riempito un bicchiere di vino rosso, ma l'idea di andare lì, dargli una pacca sulla spalla per portargli via un po’ di pelle morta è una follia, gli lavano le posate con l'azoto ad ogni pietanza, quelli lì intorno, figuriamoci. Dopo una pianificazione di tre mesi, a nessuno è venuto in mente una qualche specie di escamotage, che so. E ora io dovrei starmene qui, a sorbirmi il monologo di questo cazzo di megalomane che si vanta di far parte di una ristrettissima casta di tecnocrati semi-immortali, aspettando di poter tornare a casa con la coda fra le gambe? Non credo proprio. 
Ai piani alti non vogliono sentir parlare di fallimenti. La menata della contrattazione per quei giacimenti di tantalio in Ruanda, poi, durerà ben poco. Bill ha documentazione per girarci intorno al massimo un’ora ed io sono troppo impegnato ad avvicinarlo per poter mentire in modo credibile ancora per molto. Aspetta un momento, fermi tutti, ci sono. L'acqua. Quel Sassicaia che continua a spiluccare da mezz'ora allungherà anche la vita, come dice lui, ma l'acqua dei grandi laghi Canadesi, te la salva. Non c'è niente su questo pianeta, oggigiorno, che regga minimamente il confronto. E’ il momento di stappare un po’ di buon vecchio orgoglio nazionale, cerchiamo di attirare la sua attenzione. Eccolo che sorride e allunga il bicchiere verso di me in un brindisi, con quella testona pelata protesa in avanti, abbassa la guardia, la mano flaccida che sfiora per un attimo la mia e ci sono quasi, basta solo un colpetto innocente, una moto involontario calcolato ed è fatta. Il bicchiere scivola dalle sue dita e cade in un crocchio ovattato dalla moquette termo-sensibile che fruscia sotto i nostri piedi dove un piccolo drone, lesto lesto, esce dal muro, raccoglie i pezzi e distrae le guardie per qualche secondo. Ci siamo.
Tumblr media
Mentre Bill insiste imperterrito nella sua chiacchierata prendo l'iniziativa, allungo il mio, di bicchiere, e versandoci dentro quella preziosa, gelida, limpidissima acqua di sorgente glielo offro in dono allungandomi sul tavolo. Lui, con me li tutto stiracchiato, sorride. Il suo braccio si distende d'impulso, con grazia vetusta afferra il gambo del calice rapito dal caleidoscopio di luci che si frantuma nei flutti trasparenti stretti fra le sue dita sottili. Il vecchio bacucco c'é cascato. Prende un primo piccolo assaggio, e io lo so, che ora gli sta esplodendo in bocca la perfezione della semplicità chimica più assoluta. Ecco un altro sorso, e un altro ancora e glup, finito. Appoggiando il bicchiere lì, a mezzo tavolo, si abbandona nel poltroncino grigio e dice solo, eccezionale. Bill, lo intravedo con la coda dell'occhio, sopprime un sorriso quel tanto che basta per creare un’intesa di spirito coi presenti. E’ il momento. Con nonchalance afferro il calice, allungandomi in modo impercettibile, nell'ordine dei millimetri. Mentre tutti stanno lì a ciucciarsi la filippica di Bill sulla storia delle sorgenti Gitché Gumee, pulisco con un fazzolettino il bordo inumidito dalla preziosa saliva del matusalemme. Discreto, mi volto verso Bill con fare condiscendente, ma ecco, mentre con lo sguardo plano verso di lui, i miei occhi s'inchiodano in quelli dell'Indiano che ora mi fissano intensamente. Quasi con complicità. Io, quindi, gli sorrido. Ma lui, non fa una piega. Ed è il panico. Lui sa, mi ha visto, è ovvio. Sento il suo sguardo piantato nel mio anche mentre sto lì, a guardare Bill, stritolato dal terrore. E allora non so se sono le ostriche o gli scampi, il vino o quei maledetti datteri, ma lo stomaco, lo sento, mi strizza come un panno bagnato. Dico solo, devo andare in bagno, e con il suo sguardo ancora lì, a cercare il mio, esco.   Ecco il corridoio. La porta che si chiude alle mie spalle. Sono solo. Riprendo fiato, riordino i pensieri, ossigeno il cervello e decido che ho davvero bisogno di darmi una rinfrescata. Seguo i corridoi riavvolgendo ogni istante: io che chiacchiero, io che offro quel bicchiere e tac, me lo riprendo. E poi quello sguardo. Dove ho sbagliato? Mi ha scoperto? Forse non dovevo andarmene così, avrei dovuto aspettare, reggere il suo sguardo, mantenere la calma. La stessa che ora vacilla mentre le informazioni che dovrebbero essere proiettate sui muri cambiano, omettono, e allora meglio fermarsi, perché qualcosa, da qualche parte intorno a me, inizia a fischiare. Il suono cresce, lentamente, e mi giro a cercare altoparlanti, droni della pulizia, ma solo quando provo a tapparmi le orecchie realizzo cosa sta succedendo. Una notifica compare nell'angolo destro del mio campo visivo aumentato. E’ in corso un attacco alla mia rete neurale. Devo trovare subito dei servizi igienici. Meno male Duke mette in giro due frecce e mi ci posso fiondare dietro a perdifiato. Con lo sguardo che cerca telecamere troppo invadenti e di cattivo gusto per il quartier generale di un dio, corro e imbocco la porta dei bagni per il personale. Mi butto sul lavandino e uno, due, tre, quattro, cinque sorsi. Potrebbe essere l'ultima acqua che vedrò per un bel pezzo. Ora è meglio levare le tende. Duke, trova via d'uscita defilata verso: Strada esterna. Lui per tutta risposta mi comunica che con la sicurezza siamo ai ferri corti, sarà meglio sbrigarsi. Evitati gli sguardi distratti di un paio di guardie lungo il corridoio, raggiungo l'ascensore di servizio e precipito in caduta controllata per qualcosa come quattro minuti buoni, dritto dritto verso il suolo, sprofondandoci dentro per qualche decina di metri ed eccomi, finalmente sono ai piani di servizio. Fra gli sguardi stupiti dei pochi operai che controllano il lavorare incessante di droni dinoccolati a spasso per questi magazzini labirintici, seguo le indicazioni sempre più incerte di Duke. Devo raggiungere la metropolitana, ma per farlo, dice lui, dobbiamo risalire in superficie. Attraversata velocemente la zona scarico merci, ecco comparire un piccolo carrello elevatore di servizio per il personale su cui i miei occhi leggono: straight to the top dude, hurry up now. La luce del tramonto, a questa latitudine, è qualcosa di insostenibile e maestoso insieme.
Tumblr media
Il riverbero fiammeggiante del sole morente, schermato dai finestroni traslucidi di questi colossi verdeggianti, spande un calore secco e intenso sulla folla che brulica lungo le strade dirette verso il centro di multi-trasporto, il mio approdo dove salpare verso acque più tranquille, una zona grigia sul limitare del deserto, la slum-city di Nagaur. Le persone di questa città sembrano vagare inconsapevoli del mondo che sta loro intorno. Attraversando quell'oceano di anime intrappolate ognuna nella propria prigione di informazioni e contenuti web iperealistici, qualcosa scivola nell'anticamera del mio cervello, un presentimento di pericolo sbiadito e distante.
Scendendo nel sottosuolo, districandomi fra le indicazioni sempre più confuse per le stazioni dei Super Espressi, il senso di nausea che mi trascinavo dietro dall'incontro era diventato un mal di testa fitto, intenso, come se qualcosa stesse contagiando ogni parte del mio cervello. Duke, senza peli sulla lingua, dice, preparati, sono quasi dentro, entra in quel fottuto treno. Mentre cerco di salire, la folla intorno a me si compatta, spinge e quando la porta si apre si rilassa, fluendo verso l'interno. Prendo il primo posto a sedere che trovo, mi metto comodo e chiedo a Duke di fare subito un controllo approfondito su tutta la rete neurale, ma lui non risponde più.
Una notifica distorta nel mio campo visivo aumentato dice solo, dormi. Il mal di testa si acuisce e le poche informazioni che ricevevo s'interrompono. In questo momento la vedo la realtà, quella vera, nuda e cruda. Ma non faccio a tempo a convincermi di questo. Tutt'intorno le persone mi fissano intensamente, anche quelli lì, appesi al sedile, scrutano nella mia direzione, muti. 
La tensione non mi sta giocando un brutto scherzo, la mia è non è semplice paranoia.
Tumblr media
Una donna molto anziana, ora, siede di fronte a me. 
Veste una lunga tunica color verde. Con lo sguardo grigio, arcigno, sembra scrutare nel mio. La sua bocca allora si apre, lentamente, e sopra quel sibilo che grava sul mondo, la sua voce roca chiede: Will Be There Enough Water?
Tumblr media
[RequestCode]: Skipfoward [InsertDate] 2083/07/21 [InsertTime] 3:00[a.m.] [InsertLocation] Mundwa Mataji Road, Tejasar [RequestCode]: Confirmed [Initializing]225.245.2.9\ExodanEmployer\DD399C_backupmemory.exe
Quando mi trovo a speculare sulla funzionalità sociale di queste zone degradate ai margini della civiltà, aggrappate ad aree urbane che si stendono per milioni di chilometri quadrati, non posso fare a meno di equipararle ad uno strato di cellule epidermiche morte che si staccano progressivamente da un organismo più grande, complesso ed in continua evoluzione. Come se l'umanità fosse qualcosa di più della semplice sommatoria di ognuno di noi, qualcosa di spaventoso e grandioso assieme.
Tumblr media
Quando mi perdo dentro speculazioni come questa non riesco a non sentirmi piccolo, limitato, insignificante e sacrificabile, proprio come lo sono adesso. Nessuno verrà a prendermi. Duke, probabilmente, già lo sapeva. Il cosiddetto piano di fuga mi ha portato in un sterminato vicolo cieco di sabbia e disperazione. Le strade tentacolari che si snodano attraverso questa metropoli semi-abbandonata stritolata dal deserto, ora, nel cuore della notte, diventano l'ultima spiaggia per tribù di cyber-criminali e tossici virtuali, moribondi rinsecchiti e vecchie famiglie massacrate dalla fame. A centinaia di migliaia scappano qui, nelle zone grigie, dove il costoso walfare corporativo non trova ragione d'esistere.
Tumblr media
Gli scheletri di vecchie città di inizio secolo, invase da costruzioni di fortuna, sono diventate il rifugio di chi ha barattato una cinquantina d'anni in più con desideri e emozioni, sentimenti e bisogni. Ma anche fobie e manie, le paure più nascoste, come anche gli affetti ed i ricordi più cari. Tutte informazioni celermente raccolte ed analizzate per creare una realtà alternativa che possa compensare scelte di vita socialmente inaccettabili e insostenibili, fallimentari, fuori dai binari che ora, guarda un po’, mi hanno sbattuto in una trappola di stenti e incubi. Le allucinazioni stanno peggiorando di ora in ora, e la sete non aiuta. Prima erano solo voci amiche che sussurravano alle mie spalle, facce note perse fra la folla. Poi sono diventate punti di riferimento che scompaiono, edifici dello stesso posto che cambiano colore, forma, dimensione. Le coordinate che avrebbero dovuto portarmi ad uno scalo multi-trasporto indipendente per Amehabad sono state manomesse. Duke sta perdendo colpi più velocemente del previsto e ora, chiuso dentro questa casupola, non so nemmeno dove sono, i nano-radiatori del poncho da viaggio hanno smesso di funzionare e sono ore che non bevo una goccia d'acqua.
Tumblr media
Qui dentro, poi, sembra di stare dentro una cazzo di fossa biologica. Il reflusso esalato dalle condutture sta avvelenando l'aria ma aprire le finestre dal primo piano, con quei maledetti sciami-droni di sorveglianza che scandagliano queste case notte per notte, sarebbe un errore da novellini. La strada sui cui si affacciano, poi, non è che sia proprio un bello spettacolo. Nell'ultima mezzora saranno passati almeno quattro auto-bot della spazzatura a caricare immondizia e spazzatura elettronica bruciata da sole, detriti di costruzioni in rovina, scarti industriali ed i cadaveri dei tanti disgraziati venuti qui a morire come mosche. La luce lunare filtra attraverso lo scheletro di questa baracca pericolante e solo ora, finalmente, intravedo le foto del vecchio inquilino che troneggiano sopra pacchi ben ordinati di viveri sottovuoto scaduti decenni fa, cianfrusaglie ultrasottili di fine anni duemila, mobilia orientale di terza categoria: una catacomba anonima di memorie perdute nel tempo e nello spazio. Domani mattina, in ogni caso, qui dentro la temperatura diventerà insostenibile e dovrò scendere o andarmene. Al piano di sotto però non ci posso proprio stare, non ce la faccio. Quel corpo steso lì da chissà quanto tempo, incollato a quel materasso sbranato dalla sabbia, è una realtà che non voglio affrontare.
Il vecchio è schiattato così: incollato a quel letto in un collage di carne putrefatta e cotone sintetico. Era quella la fine a cui sarebbe andato incontro più del 70% degli over 90 nei paesi con alti spread di ricchezza. E non ci si può fare un bel niente. Il principio di economicità alla base dell'efficienza eccezionale del welfare sanitario corporativo non può sopportare il peso della generazione più numerosa nella storia dell'Uomo. L'ingorgo di anziani ultra-centenari della classe media di inizio secolo che opprimeva la società è stato virtualmente ignorato, come si era fatto per migliaia di anni per disadatti, minoranze etniche, immigrati e handicappati. In comune, questi outsider ever-green, ora, avevano la povertà: la bestia nera per antonomasia, quel grumo di ignoranza e ribellione che questa umanità proiettata verso l'immortalità non può più permettersi di bonificare, viene scaricata qui senza tanti complimenti e abbattuta, smembrata e diligentemente riciclata pezzo per pezzo. Mi ci sono volute due ore seduto qui a patire la sete, immerso in incubo che sbriciola la realtà intorno a me in un caos di asimmetrie informative, per realizzare che toh, di punto in bianco domani potrei svegliarmi morto, schiaffato in qualche server, messo in stand-by in vista di un processo sommario da svolgersi in una qualche fottutissima farm-server persa in giro per l'Asia.
Tumblr media Tumblr media
Fortunatamente, Duke, li tiene ancora a distanza. Possono hackerare il sistema, ma in quel caso subentrerebbe il backup neurale d'emergenza. Tutti i miei ricordi, le esperienze, le informazioni che costituiscono la mia intera esistenza verrebbero resettate in una frazione di secondo, e io resterei senza memoria. Mi vogliono vivo e vegeto, sano di mente. Stanno semplicemente cercando prendermi per sfinimento. L'unica soluzione, a questo punto, è cercare dell'acqua. Duke però, a pensarci bene, non dà segni di vita da più di mezz'ora. Nessuna notifica, nessun aggiornamento delle informazioni disponibili, niente di niente. E’ un altro attacco? Forse. Non lo so. I comandi per le interrogazioni non funzionano e ho come la sensazione che qui dentro, faccia sempre più caldo. I dati sulle temperature esterne davano massime di 13 gradi per la notte, com'è possibile che stia sudando? Il rilevatore biometrico dice che la febbre a 39 °.Ci risiamo. Sono loro. Lo sapevo. Ok, ok ok ok, devo restare calmo. Non posso cascarci di nuovo. Sono solo impulsi armonici che falsano la mia percezione della realtà, è tutto nella mia testa. La stanza non si sta chiudendo sopra di me. Alla porta, nessuno sta bussando insistentemente. Queste voci non esistono. Lo so, lo so lo so lo so, ma devo convincermene. Eccolo di nuovo. Il fischio adesso sembra provenire dalla strada, lì fuori. Lo sento, ma non esiste, ma lo sento. Non ho il coraggio di spiare fra le assi delle finestre, non ho il fegato di affrontare ciò che potrei vedere.  Dove cazzo è Duke quando ho bisogno di lui? Sono loro, vengono a prendermi, nascosti da qualche parte, nel mondo, bussano alla porta che sta di fronte a me e io lo so che non c'è nessuno, che sono loro da qualche parte, lo so che sta succedendo tutto dentro la mia mente. Inizia a farmi male di nuovo la testa. La luce intorno a me si abbassa gradualmente, come alla fine di un atto teatrale, i raggi della luna muoiono ed eccomi, sono qui seduto, immerso nel buio più assoluto della notte che si stende fra sabbia e cielo. Di fronte a me, però, qualcosa tenta di sovrapporsi a questo muro di tenebre.
Tumblr media
Non riuscirò a superare la notte da solo. Ormai devono aver quasi estromesso Duke dalla mia rete neurale. Sta tentando di comunicare con me. Devo concentrarmi, devo riuscire a leggere quelle parole. Il buio è attraversato da una frase che riesco a malapena ad intravedere, dice: Chiudi gli occhi, dormi Daniel. Spegniti. E io obbedisco. Spengo la rete. Chiudo gli occhi. Dormo e faccio un salto nel grande blu. Qualcosa, ora, mi sta trascina verso il basso. Sono sveglio, sto dormendo? Perché non riesco a muovermi? Non lo so. Un liquido freddo mi avvolge le membra dolcemente, le forze mi abbandonano, non riesco a respirare, soffoco, sto morendo, cristo santo sto morendo, dovrei respirare, ma un gusto di cloro mi invade la bocca e poi l'esofago ed è già nei polmoni e li riempie. Non riesco a respirare. Sto affogando, ma dove? Devo aprire gli occhi, e li apro. Davanti a me, ora, un'ombra con testa e braccia e gambe si staglia nella visione subacquea di un muro di mattonelle smaltate di un turchese cristallino, brillante. Risalgo verso la superficie, lottando contro la luce di un sole alieno che mi acceca, emergo e mi volto verso la sorgente di quell'oscurità scheletrica e lo vedo, oh sì, lo vedo bene ma davvero, no, no non posso, non devo credere a questo incubo.
Tumblr media
 Perché lo so che non sono morto, ed è dentro la mia testa per forza che quello stesso vecchio cadavere mummificato al piano di sotto ora sta lì, in piedi, sul bordo della piscina in cui galleggio e mi guarda, chiedendo: Will Be There Enough Water?
Tumblr media
Originally posted by pinkcollapse [RequestCode]: Skipfoward
[InsertDate] 2083/07/21 [InsertTime] from 6:05[am] [InsertLocation] Mundwa Mataji Road, Tejasar [RequestCode]: Confirmed [Initializing] 225.245.2.9\ExodanEmployer\DD399C_backupmemory.exe
Tumblr media
Duke? Due mi senti? Se mi senti, ti scongiuro, rispondimi. Mi serve dell'acqua. Devo trovare dell'acqua. Se sei lì da qualche parte, ti prego, aiutami. Con questa sete sta diventando faticoso anche solo pensare. Niente da fare, non risponde. E'andato. Sono rimasto solo. Non manca molto all'alba e la temperatura sta salendo. Ma questa non è un'altra allucinazione, è calore reale, radiazioni termiche autentiche. L'aria che si fa più secca in bocca, il vento che ulula più forte e la notte che brucia sotto i raggi del sole appena oltre l'orizzonte. E’ il giorno che avanza, inesorabile.
Tumblr media
I secondi sui cui tentenno ora, potrebbero essere gli ultimi. Devo muovermi, non posso aspettare oltre, qui dentro morirò asfissiato nel giro di qualche ora. Ecco il piano terra, lo scricchiolio della baracca risuona come un lamento metallico mentre il vecchio è ancora lì, che mi fissa. O ci è tornato? Lo supero in punta di piedi ed ecco la porta, sono fuori. La strada, sgranata e sfalsata da vibrazioni che posso vedere e sentire, si scioglie sotto i miei piedi ad ogni passo. Intorno a me, si muove un nugolo di sagome fumose, corpi fluttuanti che ora prendono le distanze da me, non ascoltano i miei aiuto che rimbombano lontani e si defilano senza emettere un fiato negli angoli di incroci angusti, immersi nel crepuscolo. Sono bloccato. Non riesco più muovermi. Duke? Mi senti? Cosa sta succedendo? Il terreno si sbriciola e si apre sotto di me.Cado, cado e intorno a me cala il buio. E’ un’allucinazione? Sto perdendo di nuovo il contatto con la realtà. Sopra, in alto, una luce si allontana, velocissima. Precipito ad una velocità folle in un baratro e sento l'aria frenare appena la mia corsa, ma il suono dei vestiti, delle mie urla, si spegne nel silenzio che avvolge la mia caduta verso la fine. Sto morendo? No. No perché adesso lo sento bene, il mio respiro e il cuore che batte qui sotto, come un martello pneumatico. Sono vivo, seduto qui, sul fondo dell'universo. Chiudo gli occhi, e aspetto. Qualcosa di sfuocato ora, appare in alto, a sinistra del mio campo visivo. E’ un barlume, un luccichio impercettibile come di una stella fredda e distante. Duke, sei tu? Nessuna risposta. Solo quello sfrigolio di luce, lì, perso nell'oscurità delle mie palpebre serrate, che piano piano adesso, prende forma, traccia simboli candidi nel buio, come su di una lavagna scura e impenetrabile. Gradi, latitudine, longitudine. Sono coordinate. Ma per dove? Duke, dove vuoi portarmi? Cos'è questa luce? E questo caldo? Apro gli occhi.
Tumblr media
Sono tornato alla realtà, o almeno quello che ne rimane. Quanto tempo sarà passato? Alle mie spalle, i raggi sbilenchi del sole guizzano feroci lì, oltre l'orizzonte ormai in fiamme. Devo seguire quelle coordinate. Duke, continua così, mostrami la via. Le frecce di navigazione mi stanno portando fuori dall'agglomerato urbano, verso le serre idroponiche interrate, appena oltre gli slums, in uno di quei tanti stracci di deserto che hanno invaso le campagne qui intorno. Cazzo se è’ un azzardo questo. Dovessi trovarmi lì in mezzo quando il sole si alzerà. No, non ci devo pensare. Devo fidarmi. Non ho altra scelta. Per precauzione, mi muoverò lungo i tunnel che corrono fra le serre sotterranee. 
Le indicazioni dovrebbero funzionare anche là sotto. Le allucinazioni, stranamente, paiono attenuarsi ad ogni minuto. La sete, però, resta. Tutte queste cisterne vuote e vasche dilaniate dalla ruggine, i rubinetti aridi, pompe idrauliche fossilizzate. Spero solo che quelle coordinate non siano un abbaglio, o peggio un'altra trappola. Ma non importa. In ogni caso, se non trovo dell'acqua entro qualche ora, perderò coscienza, e sarà finita. Eccolo, lì infossato in quella depressione, è uno degli accessi. Entro, devo seguire attentamente le frecce lungo questi muri viscidi e freddi che si snodano nel sottosuolo. Perdersi qui dentro, fra chilometri di teche devastate dalla sabbia che si alternano a piccoli laboratori abbandonati in fretta e furia, sarebbe fatale. Non manca molto, il sole, sorgerà fra pochi minuti. Devo sbrigarmi. Le indicazioni si fanno più serrate, i corridoi sono diventati un budello inestricabile. Destra, sinistra sinistra, destra e ancora destra e sinistra. Sto correndo, devo restare calmo. Ecco, quella dev'essere l'uscita, sale verso l'alto, verso la luce in cui mi slancio ed eccomi, sono di nuovo fuori. Cos'è questo posto? Guglie smussate dal vento sovrastano un muro di cinta antichissimo, decrepito. Dev'essere un tempio, un qualche luogo di culto, sembra abbandonato da millenni. Ogni cosa, qui intorno sembra lasciata andare a puttane, in effetti. 
Dove diavolo mi hai portato Duke? Questo stramaledetto agglomerato residenziale di fine anni ’10 è morto asfissiato da almeno cinquant'anni, dove cazzo la dovrei trovare dell'acqua qui? Le frecce ora portano dritto dritto lì dentro. C'è troppo silenzio anche per me ora. Dov'è finito il vento? E il fruscio dei rami degli alberi? 
Tumblr media
Non riesco più a capire se questa è la realtà, o qualcosa di artificiale, di precostruito, perché più avanzo verso quel portale in pietra, più il tempo sembra distendersi, rallentando come stessi camminando su un elastico spazio-temporale in tensione. Un'allucinazione? Non lo so, non mi interessa.
Non ho più le forze per preoccuparmi dei muri che ondeggiano, del portale che ora pare chiudersi alle mie spalle intrappolandomi in questa specie di sagrato dove un paio di panchine devastate dal tempo stanno lì inerti, tavolozze sbiadite su cui capeggiano scritte in sanscrito che il mio traduttore non riesce a decifrare.Il terreno sotto di me è secco, scuro, ci appoggio sopra una mano. La sabbia è fredda. Avanzo oltre un paio di leoni scolpiti nella pietra, posti di guardia dell'entrata ed ecco una porta sbarrata da assi di fortuna. Le scosto, ma nella caduta avverto solo le vibrazioni dell'impatto col suolo sotto la pianta delle scarpe. Percepisco unicamente una distorsione visiva correre lungo le colonne che sorreggono il portico, su per la porta e poi lì, fin dentro la fessura della porta, socchiusa appena.
Mi muovo all'interno con cautela, inoltrandomi nel silenzio più assoluto, non riesco a sentire nemmeno i miei stessi passi mentre avanzo in un spazio oscuro, angusto.
Tumblr media
Il sole che inizia a sorgere alle mie spalle, illumina un luogo di culto saccheggiato fino all'ultima pietra. Le frecce, corrono lungo il percorso che si staglia attraverso un colonnato basso e tarchiato, sfiorato dalla luce, fino a fermarsi davanti ad una tenda rossa aggrappata al muro dietro un possente altare in pietra. Avanzo ancora, aggiro il monolite squadrato ed eccomi, sono di fronte allo stendardo sbranato dal tempo.
Una brezza leggera, umida vi soffia attraverso. Lo afferro, e lo scosto. Dietro di esso, un tunnel stretto e buio si slancia verso il sottosuolo. I muri che scivolano verso il basso mi lasciano le dita bagnate di fresco. Qui sotto c'è acqua. No, no non può essere. Questa umidità, questo stesso vento freddo che sale da lì sotto è lo stesso che soffia nei meandri delle gelide sorgenti di casa mia. Com'è possibile? Qui, nel bel mezzo del deserto? E’ un'altra allucinazione. Lo sapevo. Lo sapevo cazzo. Le coordinate, Duke che mi contatta così, troppo semplice, troppo facile. Però questo freddo, l'aria che respiro. No, non può essere solo un'allucinazione, anche se ora sento quel fischio squarciare l'aria alle mie spalle, anche se tutto ora sembra vibrare come in un'esplosione imminente, io lo so, lo sento che qui sotto c'è qualcosa. I suoni ora, sono tornati. Dal tunnel un gorgoglio meccanico borbotta nell'oscurità, mentre quel fischio si fa assordate, riempie l'aria in cui rintoccano chiari dei passi, appena fuori dall'edificio. L'interno del templio è invaso dalla luce soffusa del sole che si staglia lì in fondo, oltre la porta, erto sopra l'orizzonte, splendente e terribile. Il calpestio, si dirige verso l'entrata. Un'ombra asciutta, compare d'innanzi a me. Una sagoma segaligna vestita di una bianco candido, glabra, infuocata dalla luce del sole, sta lì sulla soglia, e sembra osservarmi. Chi va là? La prego mi aiuti. Quello non risponde, e avanza di due passi appena, quel tanto che basta per arrivare sotto l'ombra del porticato che ridisegna il suo volto ed eccolo. Ora vedo distintamente il suo braccio steso verso di me, che stringe quello stesso calice scheggiato fra le sue dita sottili. Il turbante, raccolto intorno al suo volto, si scioglie sopra un sorriso familiare.   Lo sapevo. E’ lui. E’ sempre stato lui. Alla fine mi ha trovato. Le sue labbra, ora, si schiudono appena e chiedono: Will Be There Enough Water?
Tumblr media
[RequestCode]: PauseMemory [Copy] 225.245.2.9\ExodanEmployer\ DD399C_GPS coordinates [Open] D:\SystemPrograms\scriptedmail\@xpsp2res.dll,-22019 [Write] “Obiettivo confermato, le coordinate sono corrette” [Send] [StartServer] 223.236.2.4\OppenheimerProject\Duke [RequestCode] DeleteAllMemory [InsertCode] DD399C [Initializing] [RequestCode] Confirmed.
Tumblr media
2 notes · View notes
night-finance-site-blog · 8 years ago
Text
Intent i = new Intent(this, to.msn.wings.intentbasic.SubActivity.class); startActivity(i); Intentクラス public Intent(Context context, Class<?> clazz) startActivity(Intent i)finish(); <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LANCHER" /> </intent-filter> EditText txtName = (EditText) fidViewById(R.id.txtName); i.putExtra("txtName", txtName.getNmae.getText().toString()); startActivity(i); putExtraメソッド public Intent putExtra(String name, T value) Intent i = this.getIntent(); String txtName = i.getStringExtra("txtName"); Toast.makeText(this, String.format("%s",txtName), Toast.LENGTH_SHORT).show(); getXxxxxxExtraメソッド public T getXxxxxExtra(String name) this.startActivityForResult(i, 1); startActivityForResultメソッド public void startActivityForResult(Intent intent, int requestCode) EditText txtName = (EditText) findViewById(R.id txtName); Intent i = new Intent(); i.putExtra("txtName", txtName.getText().toString()); setResult(RESULT_OK, i); finish(); setResultメソッド public final void setResult(int resultCode, Intent data) onActivityResultメソッド protected void onActivityResult(int requestCode, int resultCode, Intent data) Intent i = new Intent(Intent.ACTION_VIEW, Uriparse(txtKeywd.getText().toString())); startActivity(i); Intentクラス public Intent(String action[,Uri uri]) Intent i = new Intent(Intetn.ACTION_SEND); i.setType("text/plain"); i.putExtra(Intent.EXTRA_TEXT, txtName.getText().toString()); setTypeメソッド public IntentType(String type) (Intent.EXTRA_TEXT) <intent-filter> <action android:name="android.intent.action.SEND" /> <data android:mimeType="text/plain" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> onCreateViewメソッド public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) <activity android:name=".DetailsActivity"> </activity> private boolean isTwoPane = false; @Override public void onActivityCreateed(Bundle savedInstanceState) { super.onActivityCreateed(savedInstanceState); if(getActivity() findViewById(R.id.detailsFrame) != null) { isTwoPane = true; Bundle bundle = new Bundle(); bundle.putStrinf("name", (String) parent.getItemAtPosition(i)); bundle.putString("name", (String) parent.getItemAtPosition(i)); if(isTwoPane) { FragmentManager manager = getFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); DetailsFragment(); fragment.setArguments(bundle); transaction.replace(R.id.detailsFrame, fragment); transaction.commit(); } else { Intent intent = new Intent(getActivity(), DetailsActivity.class); intent.putExtras(bundle); startActivity(intent); } private boolean isTwoPane = false; @Override public void onCreate(Bundle saveInstanceState) { super.onCreate(Bundle savedInstanceState) { if(getActivity() findViewById(R.id.detailsFrame) != null) { isTwoPane = true; Bundle bundle; if(isTwoPane) { bundle = getArguments(); } else { Intent intent = getActivity().getIntent(); bundle = intent.getExtra(); }
1 note · View note
probelalkhan · 8 years ago
Text
New Post has been published on Simplified Coding
New Post has been published on https://www.simplifiedcoding.net/retrofit-upload-file-tutorial/
Retrofit Upload File Tutorial - Uploading and Downloading Images
Tumblr media
(adsbygoogle = window.adsbygoogle || []).push();
Struggling to upload images to your server? Here is the Retrofit Upload File Tutorial. The retrofit library also gives an option to send the Multipart http requests, and we can use it for uploading files. So lets learn how we do this in our android project. Here I am going to use PHP and MySQL on the server side.
Contents
1 Building APIs
1.1 Creating MySQL Database
1.2 Creating PHP Project
1.3 Defining Constants
1.4 Connecting to Database
1.5 The Uploads Directory
1.6 Handling File Upload and Download
1.7 Handling API Calls
2 Retrofit Upload File Tutorial
2.1 Creating a new Project
2.2 Adding Libraries
2.3 Creating the Model Class for Response
2.4 Creating API Interface
2.5 Uploading the File
2.5.1 Creating Interface
2.5.2 Checking the Read Storage Permission
2.5.3 Choosing a File
2.5.4 Getting Absolute Path from Uri
2.5.5 Uploading the File
3 Downloading Images Back
4 Retrofit Upload File Source Code
Building APIs
We will send the file to our server from the android application. So at the server side we need to catch the file and then we need to store it on the server. To do all these tasks we create API. So lets start. Here I am using XAMPP server, you can use any other server as well.
Creating MySQL Database
The first step is creating the database. And we need a database shown as below.
Tumblr media
Database
You can use the following SQL for creating the above database.
CREATE TABLE `images` ( `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT, `description` varchar(1000) NOT NULL, `image` varchar(500) NOT NULL );
Creating PHP Project
For PHP Project I am using PHP Storm. But you can use notepad++, sublime or any other IDE as well.
Create a new project inside htdocs (c:/xampp/htdocs). I have created a project named ImageUploadApi.
Defining Constants
First we will create a file named Constants.php to define all the required constants.
<?php /** * Created by PhpStorm. * User: Belal * Date: 10/5/2017 * Time: 11:31 AM */ define('DB_HOST', 'localhost'); define('DB_USER', 'root'); define('DB_PASS', 'password'); define('DB_NAME', 'simplifiedcoding'); define('UPLOAD_PATH', '/uploads/');
Connecting to Database
Now we will connect to our database. For this create a php class named DbConnect.php and write the following code.
<?php /** * Created by PhpStorm. * User: Belal * Date: 10/5/2017 * Time: 11:31 AM */ class DbConnect private $con; public function connect() require_once dirname(__FILE__) . '/Constants.php'; $this->con = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); if (mysqli_connect_errno()) echo 'Failed to connect ' . mysqli_connect_error(); return null; return $this->con;
The Uploads Directory
Create a directory inside your project named uploads. In this folder we will store all the images uploaded by the user.
Tumblr media
Handling File Upload and Download
Now we will create one more class named FileHandler.php to save and retrieve the images.
<?php /** * Created by PhpStorm. * User: Belal * Date: 10/5/2017 * Time: 11:30 AM */ class FileHandler private $con; public function __construct() require_once dirname(__FILE__) . '/DbConnect.php'; $db = new DbConnect(); $this->con = $db->connect(); public function saveFile($file, $extension, $desc) $name = round(microtime(true) * 1000) . '.' . $extension; $filedest = dirname(__FILE__) . UPLOAD_PATH . $name; move_uploaded_file($file, $filedest); $url = $server_ip = gethostbyname(gethostname()); $stmt = $this->con->prepare("INSERT INTO images (description, url) VALUES (?, ?)"); $stmt->bind_param("ss", $desc, $name); if ($stmt->execute()) return true; return false; public function getAllFiles() $stmt = $this->con->prepare("SELECT id, description, url FROM images ORDER BY id DESC"); $stmt->execute(); $stmt->bind_result($id, $desc, $url); $images = array(); while ($stmt->fetch()) $temp = array(); $absurl = 'http://' . gethostbyname(gethostname()) . '/ImageUploadApi' . UPLOAD_PATH . $url; $temp['id'] = $id; $temp['desc'] = $desc; $temp['url'] = $absurl; array_push($images, $temp); return $images;
Handling API Calls
Lastly we need to handle the calls of our Android App. So for this we will create a php file named Api.php and in this file we will handle all the api calls.
<?php /** * Created by PhpStorm. * User: Belal * Date: 10/5/2017 * Time: 11:53 AM */ require_once dirname(__FILE__) . '/FileHandler.php'; $response = array(); if (isset($_GET['apicall'])) switch ($_GET['apicall']) case 'upload': if (isset($_POST['desc']) && strlen($_POST['desc']) > 0 && $_FILES['image']['error'] === UPLOAD_ERR_OK) $upload = new FileHandler(); $file = $_FILES['image']['tmp_name']; $desc = $_POST['desc']; if ($upload->saveFile($file, getFileExtension($_FILES['image']['name']), $desc)) $response['error'] = false; $response['message'] = 'File Uploaded Successfullly'; else $response['error'] = true; $response['message'] = 'Required parameters are not available'; break; case 'getallimages': $upload = new FileHandler(); $response['error'] = false; $response['images'] = $upload->getAllFiles(); break; echo json_encode($response); function getFileExtension($file) $path_parts = pathinfo($file); return $path_parts['extension'];
Now lets test our API and for this we can use any REST Client. I am using POSTMAN.
Tumblr media
Testing API
So our API is working fine. Now lets move into the Android Part.
Retrofit Upload File Tutorial
Here begins the main part. The first step always is creating a new Android Studio Project.
Creating a new Project
I have created a project named RetrofitFileUpload.
Now once the project is completely loaded we will add the Retrofit and Gson to it.
Adding Libraries
Come inside app level build.gradle file and add the following given lines to it inside the dependencies block.
dependencies compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', exclude group: 'com.android.support', module: 'support-annotations' ) compile 'com.android.support:appcompat-v7:26.+' compile 'com.android.support.constraint:constraint-layout:1.0.2' //these two lines are added compile 'com.squareup.retrofit2:retrofit:2.3.0' compile 'com.squareup.retrofit2:converter-gson:2.2.0' testCompile 'junit:junit:4.12'
Now sync your project.
Creating the Model Class for Response
The response we are getting from the server is.
"error": false, "message": "File Uploaded Successfullly"
So to parse it we will create a model class. So create a class named MyResponse.java and write the following code.
package net.simplifiedlearning.retrofitfileupload; /** * Created by Belal on 10/5/2017. */ public class MyResponse boolean error; String message;
Creating API Interface
Now we need an interface to define all the API calls. So create an interface named Api.java and write the following code.
package net.simplifiedlearning.retrofitfileupload; import okhttp3.RequestBody; import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.http.Multipart; import retrofit2.http.POST; import retrofit2.http.Part; /** * Created by Belal on 10/5/2017. */ public interface Api //the base URL for our API //make sure you are not using localhost //find the ip usinc ipconfig command String BASE_URL = "http://192.168.43.124/ImageUploadApi/"; //this is our multipart request //we have two parameters on is name and other one is description @Multipart @POST("Api.php?apicall=upload") Call<MyResponse> uploadImage(@Part("image\"; filename=\"myfile.jpg\" ") RequestBody file, @Part("desc") RequestBody desc);
Uploading the File
Creating Interface
To upload a file we need a file, and to get the file we will create a file chooser. So we will create a button and by tapping this button we will open a file chooser activity.
So first create a button inside activity_main.xml.
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="net.simplifiedlearning.retrofitfileupload.MainActivity"> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="Upload Image" /> </RelativeLayout>
Checking the Read Storage Permission
So if the android is running the version greater than Lollipop then we need to ask for the permission on run time. But we also need to define the permission in the manifest file. The permission here is the Read Storage Permission as to upload a file first we need to read the file from the storage and without storage permission we cannot do it.
So first open AndroidManifest.xml and define the read permission.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.simplifiedlearning.retrofitfileupload"> <!-- read and internet permission --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
We also defined the internet permission as this is also needed. But we don’t need to ask internet permission on runtime.  So on onCreate() we will add the following code.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + getPackageName())); finish(); startActivity(intent); return;
The above code will stop the application and open the settings page, if the app is not having the read storage permission.
Choosing a File
We will add the following code on Button Click Event to open the file chooser.
Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(i, 100);
Now we also need to track the result of this file chooser intent. And to do this we need to override the method onActivityResult().
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) super.onActivityResult(requestCode, resultCode, data); if (requestCode == 100 && resultCode == RESULT_OK && data != null) //the image URI Uri selectedImage = data.getData();
We got the image Uri but it is not enough we need to actual image path. For this we will create one more method.
Getting Absolute Path from Uri
For getting the absolute path we can use the following method.
/* * This method is fetching the absolute path of the image file * if you want to upload other kind of files like .pdf, .docx * you need to make changes on this method only * Rest part will be the same * */ private String getRealPathFromURI(Uri contentUri) String[] proj = MediaStore.Images.Media.DATA; CursorLoader loader = new CursorLoader(this, contentUri, proj, null, null, null); Cursor cursor = loader.loadInBackground(); int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); String result = cursor.getString(column_index); cursor.close(); return result;
Uploading the File
Now to upload the file we will create the following method.
private void uploadFile(Uri fileUri, String desc) //creating a file File file = new File(getRealPathFromURI(fileUri)); //creating request body for file RequestBody requestFile = RequestBody.create(MediaType.parse(getContentResolver().getType(fileUri)), file); RequestBody descBody = RequestBody.create(MediaType.parse("text/plain"), desc); //The gson builder Gson gson = new GsonBuilder() .setLenient() .create(); //creating retrofit object Retrofit retrofit = new Retrofit.Builder() .baseUrl(Api.BASE_URL) .addConverterFactory(GsonConverterFactory.create(gson)) .build(); //creating our api Api api = retrofit.create(Api.class); //creating a call and calling the upload image method Call<MyResponse> call = api.uploadImage(requestFile, descBody); //finally performing the call call.enqueue(new Callback<MyResponse>() @Override public void onResponse(Call<MyResponse> call, Response<MyResponse> response) if (!response.body().error) Toast.makeText(getApplicationContext(), "File Uploaded Successfully...", Toast.LENGTH_LONG).show(); else Toast.makeText(getApplicationContext(), "Some error occurred...", Toast.LENGTH_LONG).show(); @Override public void onFailure(Call<MyResponse> call, Throwable t) Toast.makeText(getApplicationContext(), t.getMessage(), Toast.LENGTH_LONG).show(); );
Now we just need to club everything inside our MainActivity.java.
package net.simplifiedlearning.retrofitfileupload; import android.Manifest; import android.content.Intent; import android.content.pm.PackageManager; import android.database.Cursor; import android.net.Uri; import android.os.Build; import android.provider.MediaStore; import android.provider.Settings; import android.support.v4.content.ContextCompat; import android.support.v4.content.CursorLoader; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Toast; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import java.io.File; import java.io.IOException; import okhttp3.MediaType; import okhttp3.RequestBody; import okhttp3.ResponseBody; import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; import retrofit2.Retrofit; import retrofit2.converter.gson.GsonConverterFactory; public class MainActivity extends AppCompatActivity @Override protected void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //checking the permission if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + getPackageName())); finish(); startActivity(intent); return; //adding click listener to button findViewById(R.id.button).setOnClickListener(new View.OnClickListener() @Override public void onClick(View view) //opening file chooser Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(i, 100); ); @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) super.onActivityResult(requestCode, resultCode, data); if (requestCode == 100 && resultCode == RESULT_OK && data != null) //the image URI Uri selectedImage = data.getData(); //calling the upload file method after choosing the file uploadFile(selectedImage, "My Image"); private void uploadFile(Uri fileUri, String desc) //creating a file File file = new File(getRealPathFromURI(fileUri)); //creating request body for file RequestBody requestFile = RequestBody.create(MediaType.parse(getContentResolver().getType(fileUri)), file); RequestBody descBody = RequestBody.create(MediaType.parse("text/plain"), desc); //The gson builder Gson gson = new GsonBuilder() .setLenient() .create(); //creating retrofit object Retrofit retrofit = new Retrofit.Builder() .baseUrl(Api.BASE_URL) .addConverterFactory(GsonConverterFactory.create(gson)) .build(); //creating our api Api api = retrofit.create(Api.class); //creating a call and calling the upload image method Call<MyResponse> call = api.uploadImage(requestFile, descBody); //finally performing the call call.enqueue(new Callback<MyResponse>() @Override public void onResponse(Call<MyResponse> call, Response<MyResponse> response) if (!response.body().error) Toast.makeText(getApplicationContext(), "File Uploaded Successfully...", Toast.LENGTH_LONG).show(); else Toast.makeText(getApplicationContext(), "Some error occurred...", Toast.LENGTH_LONG).show(); @Override public void onFailure(Call<MyResponse> call, Throwable t) Toast.makeText(getApplicationContext(), t.getMessage(), Toast.LENGTH_LONG).show(); ); /* * This method is fetching the absolute path of the image file * if you want to upload other kind of files like .pdf, .docx * you need to make changes on this method only * Rest part will be the same * */ private String getRealPathFromURI(Uri contentUri) String[] proj = MediaStore.Images.Media.DATA; CursorLoader loader = new CursorLoader(this, contentUri, proj, null, null, null); Cursor cursor = loader.loadInBackground(); int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); cursor.moveToFirst(); String result = cursor.getString(column_index); cursor.close(); return result;
Now try running your application you will see something like this.
Tumblr media
Retrofit Upload File Tutorial
You can see it is working absolutely fine.
Downloading Images Back
We have already created an API call to fetch the images.
Tumblr media
Now we will use this API Call to fetch the images. And the best thing is I already posted a tutorial of Retrofit where you can learn fetching JSON from server. And I also posted a tutorial about creating RecyclerView using JSON data. So visit the posts from the below link to complete the fetching part of this tutorial.
Retrofit Android Example – Fetching JSON from URL
Expandable RecyclerView Android – RecyclerView with Expandable Items
Retrofit Upload File Source Code
In case you are having any troubles you can get my source code from here. The source code contains all the php scripts and the android project.
Retrofit Upload File Source Code Download
So thats all for this Retrofit Upload File Tutorial guys. If you are having any questions then please leave your comments. And if you found this post helpful then please SHARE it. Thank You 🙂
0 notes
aurelliocheek · 5 years ago
Text
Improving inter-activity communication with Jetpack ActivityResult
Posted by Yacine Rezgui, Developer Advocate
Whether you’re requesting a permission, selecting a file from the system file manager, or expecting data from a 3rd party app, passing data between activities is a core element in inter-process communication on Android. We’ve recently released the new ActivityResult APIs to help handle these activity results.
Previously, to get results from started activities, apps needed to implement an onActivityResult() method in their activities and fragments, check which requestCode a result is referring to, verify that the requestCode is OK, and finally inspect its result data or extended data.
This leads to complicated code, and it doesn’t provide a type-safe interface for expected arguments when sending or receiving data from an activity.
What are the ActivityResult APIs?
The ActivityResult APIs were added to the Jetpack activity and fragment libraries, making it easier to get results from activities by providing type-safe contracts. These contracts define expected input and result types for common actions like taking a picture or requesting a permission, while also providing a way to create your own contracts.
The ActivityResult APIs provide components for registering for an activity result, launching a request, and handling its result once it is returned by the system. You can also receive the activity result in a separate class from where the activity is launched and still rely on the type-safe contracts.
How to use it
To demonstrate how to use the ActivityResult APIs, let’s go over an example where we’re opening a document.
First, you need to add the following dependencies to your gradle file:
repositories { google() maven() } dependencies { implementation "androidx.activity:activity:1.2.0-alpha02" implementation "androidx.activity:fragment:1.3.0-alpha02" }
You need to register a callback along with the contract that defines its input and output types.
In this context, GetContent() refers to the ACTION_GET_DOCUMENT intent, and is one of the default contracts already defined in the Activity library. You can find the complete list of contracts here.
val getContent = registerForActivityResult(GetContent()) { uri: Uri? -> // Handle the returned Uri }
Now we need to launch our activity using the returned launcher. As you can set a mime type filter when listing the selectable files, GetContent.launch() will accept a string as a parameter:
val getContent = registerForActivityResult(GetContent()) { uri: Uri? -> // Handle the returned Uri } override fun onCreate(savedInstanceState: Bundle?) { // ... val selectButton = findViewById<Button>(R.id.select_button) selectButton.setOnClickListener { // Pass in the mime type you'd like to allow the user to select // as the input getContent.launch("image/*") } }
Once an image has been selected and you return to your activity, your registered callback will be executed with the expected results. As you saw through the code snippets, ActivityResult brings an easier developer experience when dealing with results from activities.
Start using Activity 1.2.0-alpha02 and Fragment 1.3.0-alpha02 for a type-safe way to handle your intent results with the new ActivityResult APIs.
Let us know what you think and how we can make it better by providing feedback on the issue tracker.
Improving inter-activity communication with Jetpack ActivityResult published first on https://phonetracking.tumblr.com/ Improving inter-activity communication with Jetpack ActivityResult published first on https://leolarsonblog.tumblr.com/
0 notes
leolarsonblog · 5 years ago
Text
Improving inter-activity communication with Jetpack ActivityResult
Posted by Yacine Rezgui, Developer Advocate
Whether you're requesting a permission, selecting a file from the system file manager, or expecting data from a 3rd party app, passing data between activities is a core element in inter-process communication on Android. We’ve recently released the new ActivityResult APIs to help handle these activity results.
Previously, to get results from started activities, apps needed to implement an onActivityResult() method in their activities and fragments, check which requestCode a result is referring to, verify that the requestCode is OK, and finally inspect its result data or extended data.
This leads to complicated code, and it doesn’t provide a type-safe interface for expected arguments when sending or receiving data from an activity.
What are the ActivityResult APIs?
The ActivityResult APIs were added to the Jetpack activity and fragment libraries, making it easier to get results from activities by providing type-safe contracts. These contracts define expected input and result types for common actions like taking a picture or requesting a permission, while also providing a way to create your own contracts.
The ActivityResult APIs provide components for registering for an activity result, launching a request, and handling its result once it is returned by the system. You can also receive the activity result in a separate class from where the activity is launched and still rely on the type-safe contracts.
How to use it
To demonstrate how to use the ActivityResult APIs, let’s go over an example where we’re opening a document.
First, you need to add the following dependencies to your gradle file:
repositories { google() maven() } dependencies { implementation "androidx.activity:activity:1.2.0-alpha02" implementation "androidx.activity:fragment:1.3.0-alpha02" }
You need to register a callback along with the contract that defines its input and output types.
In this context, GetContent() refers to the ACTION_GET_DOCUMENT intent, and is one of the default contracts already defined in the Activity library. You can find the complete list of contracts here.
val getContent = registerForActivityResult(GetContent()) { uri: Uri? -> // Handle the returned Uri }
Now we need to launch our activity using the returned launcher. As you can set a mime type filter when listing the selectable files, GetContent.launch() will accept a string as a parameter:
val getContent = registerForActivityResult(GetContent()) { uri: Uri? -> // Handle the returned Uri } override fun onCreate(savedInstanceState: Bundle?) { // ... val selectButton = findViewById<Button>(R.id.select_button) selectButton.setOnClickListener { // Pass in the mime type you'd like to allow the user to select // as the input getContent.launch("image/*") } }
Once an image has been selected and you return to your activity, your registered callback will be executed with the expected results. As you saw through the code snippets, ActivityResult brings an easier developer experience when dealing with results from activities.
Start using Activity 1.2.0-alpha02 and Fragment 1.3.0-alpha02 for a type-safe way to handle your intent results with the new ActivityResult APIs.
Let us know what you think and how we can make it better by providing feedback on the issue tracker.
Improving inter-activity communication with Jetpack ActivityResult published first on https://phonetracking.tumblr.com/
0 notes
donaldlockhart · 5 years ago
Text
Improving inter-activity communication with Jetpack ActivityResult
Posted by Yacine Rezgui, Developer Advocate
Whether you're requesting a permission, selecting a file from the system file manager, or expecting data from a 3rd party app, passing data between activities is a core element in inter-process communication on Android. We’ve recently released the new ActivityResult APIs to help handle these activity results.
Previously, to get results from started activities, apps needed to implement an onActivityResult() method in their activities and fragments, check which requestCode a result is referring to, verify that the requestCode is OK, and finally inspect its result data or extended data.
This leads to complicated code, and it doesn’t provide a type-safe interface for expected arguments when sending or receiving data from an activity.
What are the ActivityResult APIs?
The ActivityResult APIs were added to the Jetpack activity and fragment libraries, making it easier to get results from activities by providing type-safe contracts. These contracts define expected input and result types for common actions like taking a picture or requesting a permission, while also providing a way to create your own contracts.
The ActivityResult APIs provide components for registering for an activity result, launching a request, and handling its result once it is returned by the system. You can also receive the activity result in a separate class from where the activity is launched and still rely on the type-safe contracts.
How to use it
To demonstrate how to use the ActivityResult APIs, let’s go over an example where we’re opening a document.
First, you need to add the following dependencies to your gradle file:
repositories { google() maven() } dependencies { implementation "androidx.activity:activity:1.2.0-alpha02" implementation "androidx.activity:fragment:1.3.0-alpha02" }
You need to register a callback along with the contract that defines its input and output types.
In this context, GetContent() refers to the ACTION_GET_DOCUMENT intent, and is one of the default contracts already defined in the Activity library. You can find the complete list of contracts here.
val getContent = registerForActivityResult(GetContent()) { uri: Uri? -> // Handle the returned Uri }
Now we need to launch our activity using the returned launcher. As you can set a mime type filter when listing the selectable files, GetContent.launch() will accept a string as a parameter:
val getContent = registerForActivityResult(GetContent()) { uri: Uri? -> // Handle the returned Uri } override fun onCreate(savedInstanceState: Bundle?) { // ... val selectButton = findViewById<Button>(R.id.select_button) selectButton.setOnClickListener { // Pass in the mime type you'd like to allow the user to select // as the input getContent.launch("image/*") } }
Once an image has been selected and you return to your activity, your registered callback will be executed with the expected results. As you saw through the code snippets, ActivityResult brings an easier developer experience when dealing with results from activities.
Start using Activity 1.2.0-alpha02 and Fragment 1.3.0-alpha02 for a type-safe way to handle your intent results with the new ActivityResult APIs.
Let us know what you think and how we can make it better by providing feedback on the issue tracker.
Improving inter-activity communication with Jetpack ActivityResult published first on https://phonetracking.tumblr.com/
0 notes
whitehat-solutions · 6 years ago
Text
How to finish the parent activity from child activity
finishing a parent activity  from child activity can be implement by starting the child activity using the startActivityForResult and implement the onActivityResult to process the result return by the child activity. For Example if you have two activities ParentActivity and ChildActivity Implement the following code in Parent Activity /*start the child activity for a result*/ //bundle your stuff to pass data from parent activity to child activity Bundle bundle = new Bundle(); bundle.putInt("category", 1); Intent done = new Intent(ParentActivity.this, ChildActivity.class);done.putExtras(bundle);//start the activity for result startActivityForResult(done,1); Now implement the onActivityResult in parent activity @Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data)  {     super.onActivityResult(requestCode, resultCode, data);     //matches the result code passed from ChildActivity     if(resultCode == 0)      {                        //kill self         ParentActivity.this.finish();     } } Implement the following code in ChildActivity @Override    public void onStop()    {        super.onStop();        this.setResult(0);    }@Override    public void onDestroy()    {        super.onDestroy();        this.setResult(0);    } Enjoy Creative Android Apps
0 notes
windows98tips · 6 years ago
Text
Using Speech Engine in Android
This post is focusing on speech engine in Android SDK. The TTS engine is very important component of the Android SDK and the Android 4.0 version has great APIs to write the custom TTS engines. Here i am explaining a sample code to use the TTS engine in your android application. Create the following layout in your android application. Here is the code of the sample speak activity you can just copy and paste this in your application project. package com.example.speaksample; import android.os.Bundle; import android.app.Activity; import android.view.Menu; import android.view.MenuItem; import android.support.v4.app.NavUtils; import android.app.Activity; import android.os.Bundle; import android.view.View.OnClickListener; import android.widget.Button; import android.view.View; import android.widget.EditText; import android.speech.tts.TextToSpeech; import android.speech.tts.TextToSpeech.OnInitListener; import android.content.Intent; import java.util.Locale; import android.widget.Toast; public class speaksample extends Activity implements OnClickListener, OnInitListener { //Create the TTS object private TextToSpeech TTSObject; //status check code private int DATA_CHECK_CODE = 0; //create the Activity public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_speaking_android); //get a reference to the button element listed in the XML layout Button speakButton = (Button)findViewById(R.id.speakenglish); //set the click listener speakButton.setOnClickListener(this); //check for TTS data Intent checkTTSIntent = new Intent(); checkTTSIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA); startActivityForResult(checkTTSIntent, DATA_CHECK_CODE); } //respond to button clicks public void onClick(View v) { //get the text entered EditText inputtext = (EditText)findViewById(R.id.inputtext); String data = inputtext.getText().toString(); speakInEnglish(data); } //speak the user text private void speakInEnglish(String speech) { //speak straight away TTSObject.speak(speech, TextToSpeech.QUEUE_FLUSH, null); } //act on result of TTS data check protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == DATA_CHECK_CODE) { if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) { //the user has the necessary data - create the TTS TTSObject = new TextToSpeech(this, this); } else { //no data - install it now Intent installTTSIntent = new Intent(); installTTSIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA); startActivity(installTTSIntent); } } } //setup TTS public void onInit(int initStatus) { //check for successful instantiation if (initStatus == TextToSpeech.SUCCESS) { if(TTSObject.isLanguageAvailable(Locale.US)==TextToSpeech.LANG_AVAILABLE) TTSObject.setLanguage(Locale.US); } else if (initStatus == TextToSpeech.ERROR) { Toast.makeText(this, "TTS engine fails", Toast.LENGTH_LONG).show(); } } } If you like the code please share your feedback. Thanks
0 notes
jacob-cs · 8 years ago
Text
Android wear 개발방법(Adding Voice Capabilities)
original source: https://developer.android.com/training/wearables/apps/voice.html
두종류의 voice action types
System-provided  이미 시스템상에서 지정된 voice action
App-provided  app에서 지정하거나 특정 app의 activity를 실행하는 경우
Declare System-provided Voice Actions
When users speak the voice action, your app can filter for the intent that is fired to start an activity. If you want to start a service to do something in the background, show an activity as a visual cue and start the service in the activity. Make sure to call finish() when you want to get rid of the visual cue.
<activity android:name="MyNoteActivity">      <intent-filter>          <action android:name="android.intent.action.SEND" />          <category android:name="com.google.android.voicesearch.SELF_NOTE" />      </intent-filter>  </activity>
몇몇의 voice intent의 예시들
Tumblr media
더 많은 voice intent를 참조하려명  see Common intents.
Declare App-provided Voice Actions
you can start your apps directly with a "Start MyActivityName" voice action.
<application>  <activity android:name="StartRunActivity" android:label="MyRunningApp">      <intent-filter>          <action android:name="android.intent.action.MAIN" />          <category android:name="android.intent.category.LAUNCHER" />      </intent-filter>  </activity> </application>
label에 해당하는 내용이 Start 다음에 들어갈 명령어에 해당한다.
Obtaining Free-form Speech Input(사용자로 부터 음성으로 입력값을 받는 방법)
private static final int SPEECH_REQUEST_CODE = 0; // Create an intent that can start the Speech Recognizer activity private void displaySpeechRecognizer() {    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,            RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); // Start the activity, the intent will be populated with the speech text    startActivityForResult(intent, SPEECH_REQUEST_CODE); } // This callback is invoked when the Speech Recognizer returns. // This is where you process the intent and extract the speech text from the intent. @Override protected void onActivityResult(int requestCode, int resultCode,        Intent data) {    if (requestCode == SPEECH_REQUEST_CODE && resultCode == RESULT_OK) {        List<String> results = data.getStringArrayListExtra(                RecognizerIntent.EXTRA_RESULTS);        String spokenText = results.get(0);        // Do something with spokenText    }    super.onActivityResult(requestCode, resultCode, data); }
startActivityForResult() 를 통해 음성으로 입력값을 받을 activity를 실행한다.이때 action은  ACTION_RECOGNIZE_SPEECH 으로 지정한다. 그리고 그 결과는  onActivityResult() 에서 받을수 있다.
0 notes