Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
An Android Application on Programming Language Comparison Submitted by T. Y. B. Tech Snapshots: 1- Create new project e.g.-LanguageCmp 2- Create an activity Main_Activity.java package com.javacodegeeks.android.tts; import import import import import import import import import import import import import android.app.Activity; android.content.Intent; android.os.Bundle; android.speech.tts.TextToSpeech; android.speech.tts.TextToSpeech.OnInitListener; android.view.View; android.view.View.OnClickListener; android.widget.ArrayAdapter; android.widget.Button; android.widget.Spinner; android.widget.TextView; android.widget.Toast; com.javacodegeeks.android.cmp.R; public class TtsActivity extends Activity implements OnInitListener { private int MY_DATA_CHECK_CODE = 0; private Button cmpButton; private Spinner spine1,spine2; private TextView v3; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String[] lang={"C","C++","Java","C#.Net"}; //start the second Activity ArrayAdapter<String> adapter1=new ArrayAdapter<String>(TtsActivity.this,android.R.layout.simple_spinne r_item,lang); ArrayAdapter<String> adapter2=new ArrayAdapter<String>(TtsActivity.this,android.R.layout.simple_spinne r_item,lang); cmpButton = (Button) findViewById(R.id.compare_button); spine1=(Spinner) findViewById(R.id.spinner1); spine2=(Spinner) findViewById(R.id.spinner2); v3=(TextView)findViewById(R.id.textView3); spine1.setAdapter(adapter1); spine2.setAdapter(adapter2); cmpButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String txt=""; if(spine1.getSelectedItem()==spine2.getSelectedItem()) { v3.setText("You are selected same langauge.\n"); } else { //completed if(spine1.getSelectedItem()=="C" && spine2.getSelectedItem()=="C++" || spine1.getSelectedItem()=="C++" && spine2.getSelectedItem()=="C") { txt=txt+"1. - C is Procedure oriented langauge.\n"; txt=txt+"1. - C++ is Object oriented langauge.\n\n"; txt=txt+"2. - C -> filename extensions .c .\n"; txt=txt+"2. - C++ -> filename extensions .cc, .cpp, .cxx, .h, .hh, .hpp .\n\n"; txt=txt+"3. - C -> Designed by 'Dennis Ritchie'.\n"; txt=txt+"3. - C++ -> Designed by 'Bjarne Stroustrup'.\n\n"; txt=txt+"4. - C -> Influenced by B (BCPL,CPL),ALGOL 68,Assembly.\n"; txt=txt+"4. - C++ -> Influenced by C, Simula, Ada 83, ALGOL 68, CLU, ML.\n"; } //completed if(spine1.getSelectedItem()=="C" && spine2.getSelectedItem()=="Java" || spine1.getSelectedItem()=="Java" && spine2.getSelectedItem()=="C") { txt=txt+"1. - C is function oriented langauge.\n"; txt=txt+"1. - Java is Object oriented langauge.\n\n"; txt=txt+"2. - C allocating memory using malloc function.\n"; txt=txt+"2. - Java allocating memory using new operator.\n\n"; txt=txt+"3. - C de-allocating memory using free function.\n"; txt=txt+"3. - Java de-allocating memory using automatic garbage collection.\n\n"; txt=txt+"4. - C declaring constant using const and #define.\n"; txt=txt+"4. - Java declaring constants using final.\n"; } // if(spine1.getSelectedItem()=="C" && spine2.getSelectedItem()=="C#.Net" || spine1.getSelectedItem()=="C#.Net" && spine2.getSelectedItem()=="C") { txt=txt+"1. - C is Procedure oriented langauge.\n"; txt=txt+"1. - C#.Net is Object oriented langauge.\n\n"; txt=txt+"2. - C is Procedure oriented langauge.\n"; txt=txt+"2. - C#.Net is Object oriented langauge.\n\n"; txt=txt+"3. - C is Procedure oriented langauge.\n"; txt=txt+"3. - C#.Net is Object oriented langauge.\n\n"; txt=txt+"4. - C is Procedure oriented langauge.\n"; txt=txt+"4. - C#.Net is Object oriented langauge.\n"; } //completed if(spine1.getSelectedItem()=="C++" && spine2.getSelectedItem()=="Java" || spine1.getSelectedItem()=="Java" && spine2.getSelectedItem()=="C++") { txt=txt+"1. - C++ is Object oriented langauge.\n"; txt=txt+"1. - Java is Pure Object oriented langauge.\n\n"; txt=txt+"2. - C++ Strongly influenced by C syntax, with Object-Oriented features added.\n"; txt=txt+"2. - Java Strongly influenced by C++/C syntax.\n\n"; txt=txt+"3. - C++ Runs as native executable machine code for the target instruction sets.\n"; txt=txt+"3. - Java Runs in a virtual machine..\n\n"; txt=txt+"4. - C++ Supports the goto statement.\n"; txt=txt+"4. - Java Supports labels with loops and statement blocks.\n"; } if(spine1.getSelectedItem()=="C++" && spine2.getSelectedItem()=="C#.Net" || spine1.getSelectedItem()=="C#.Net" && spine2.getSelectedItem()=="C++") { txt=txt+"1. - C++ is Procedure oriented langauge.\n"; txt=txt+"1. - C#.Net is Object oriented langauge.\n\n"; txt=txt+"2. - C++ is Procedure oriented langauge.\n"; txt=txt+"2. - C#.Net is Object oriented langauge.\n\n"; txt=txt+"3. - C++ is Procedure oriented langauge.\n"; txt=txt+"3. - C#.Net is Object oriented langauge.\n\n"; txt=txt+"4. - C++ is Procedure oriented langauge.\n"; txt=txt+"4. - C#.Net is Object oriented langauge.\n"; } if(spine1.getSelectedItem()=="Java" && spine2.getSelectedItem()=="C#.Net" || spine1.getSelectedItem()=="C#.Net" && spine2.getSelectedItem()=="Java") { txt=txt+"1. - Java is Procedure oriented langauge.\n"; txt=txt+"1. - C#.Net is Object oriented langauge.\n\n"; txt=txt+"2. - Java is Procedure oriented langauge.\n"; txt=txt+"2. - C#.Net is Object oriented langauge.\n\n"; txt=txt+"3. - Java is Procedure oriented langauge.\n"; txt=txt+"3. - C#.Net is Object oriented langauge.\n\n"; txt=txt+"4. - Java is Procedure oriented langauge.\n"; txt=txt+"4. - C#.Net is Object oriented langauge.\n"; } v3.setText(txt); } } }); Intent checkIntent = new Intent(); checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DAT A); startActivityForResult(checkIntent, MY_DATA_CHECK_CODE); } protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == MY_DATA_CHECK_CODE) { if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) { } else { // missing data, install it Intent installIntent = new Intent(); installIntent.setAction(TextToSpeech.Engine.ACTION_INSTALL_TTS _DATA); startActivity(installIntent); } } } @Override public void onInit(int status) { if (status == TextToSpeech.SUCCESS) { Toast.makeText(TtsActivity.this, "Text-To-Speech engine is initialized", Toast.LENGTH_LONG).show(); } else if (status == TextToSpeech.ERROR) { Toast.makeText(TtsActivity.this, "Error occurred while initializing TextTo-Speech engine", Toast.LENGTH_LONG).show(); } } } 3- Create layout main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Select Language" android:textAppearance="?android:attr/textAppearanceMedium" /> <Spinner android:id="@+id/spinner1" android:layout_width="fill_parent" android:layout_height="48dp" /> <TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Compare with" android:textAppearance="?android:attr/textAppearanceMedium" /> <Spinner android:id="@+id/spinner2" android:layout_width="fill_parent" android:layout_height="48dp" /> <Button android:id="@+id/compare_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Compare" /> <TextView android:id="@+id/textView3" android:layout_width="wrap_content" android:layout_height="match_parent" android:text="" android:textAppearance="?android:attr/textAppearanceMedium" /> </LinearLayout> 4.Android Manifest.xml file <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.javacodegeeks.android.cmp" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name="com.javacodegeeks.android.tts.TtsActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-sdk android:minSdkVersion="4" /> </manifest> Conclusion: Thus we have studied how to develop android project in Mobile Application Development. In this way we have created Language Comparioson application.