ICP 4 - Hiresh12/CS5551_Team6_1_17_ICP_1 GitHub Wiki

Team Details

Team-6

  1. Hiresh Jakkala Bhaskar(class id - 17)
  2. Bharath Kumar Eilane(class id - 12)

Objective

  1. To Create an Android application which will have two activities i.e. Login and Translate.
  2. Login Activity will get username and password as inputs and validate them with my name
  3. Translate Activity will take input language ,output language and text which needs to be translated.
  4. Logout button in the translate page to take user back to Login Activity.

Code Explanation

UI

Code has been developed in Android Studio. Edit text is used get username and password from the user.

Below code represent how to validate user's username and password as 'Hiresh'.

Intent class and start activity method is used to redirect from login to translate page.

Spinner class is used to display options of language to which the text has to be translated and input is to provided.

Below code represents how to bind values to the Spinner

Language Class is created. It has two variables Language name and code. Value binded to the spinner is of type Language.

Once user click convert button. Translate method will be called. In that i have read the i/p and o/p languages from spinner , text and sends it to the API and displays the translated text to user. API URL : "https://translate.yandex.net/api/v1.5/tr.json/translate?" + "key=trnsl.1.1.20151023T145251Z.bf1ca7097253ff7e." + "c0b0a88bea31ba51f72504cc0cc42cf891ed90d2&text=" + sourceText +"&" + "lang="+fromLang+"-"+toLang+"&[format=plain]&[options=1]&[callback=set]"

Output

Button is created in translate_Activity for logout function.

Once the logout button is clicked it will trigger logout method. Intent class and start activity method is used to redirect from translate to login page.

Conclusion

Finally Android app has been developed to translate text from one language to another.

Video Link

https://youtu.be/zh2KtsPrOxw

Bonus:

  1. Differentiate –Linear, Framed, Relative & Constrained layouts. In Linear layout, children containers are organised in linear or vertical fashion. In Relative layout, children containers can be traced easily. Just like tree structure. In Framed layouts, to load child one above another, like cards inside a frame, we can place one above another or anywhere inside the frame. In Constrained layouts, it is similar to a Relative Layout in that it uses relations to position and size widgets, but has additional flexibility and is easier to use in the Layout Editor.

  2. Differentiate –implicit and explicit intent. Explicit intents are used to call application activity whereas implicit intents are used to call system level activity to choose the target.

  3. Do the android apps have main() –Justify your answer in either case. There is no need of main() for android apps, In the case of Android, the Dalvik Virtual Machine is designed to find a class which is a subclass of Activity and which is set as a LAUNCHER to start the execution of the application from its onCreate() method, so there is no need of a main() method.