This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
// We Are going to download Web Content. | |
// 1) we start by creating a new class. | |
public class DownloadTask extends AsyncTask<String, Void, String> { | |
// a class is a collection of methods and variables that we can use in our app. | |
// AsyncTask: is a way of running our code on a different thread than the main thread. | |
// so far we used onCreate method thread which known as ui thread. it is advised to run | |
// any code that gets a bit of time on a different thread rather than the main thread. | |
// so we are creating some code that will be run in background. | |
// AsyncTask usually gets 3 parameter. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Defining a Media Player: | |
MediaPlayer mediaPlayer; | |
// Giving the Media Player a sound to play | |
mediaPlayer =MediaPlayer.create(this,R.raw.music); | |
// Getting lenght of file in media player. | |
int musicLength = mediaPlayer.getDuration(); | |
// getting the current position of sound while playing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Defining Audio Manager: | |
AudioManager audioManager; | |
// Getting System Service of Audio Manager | |
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); | |
// Getting the MaxVolume of Phone | |
int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); | |
// Getting the Current Sound of Phone |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
txtScore.setText(new DecimalFormat("00").format(noCorrectAnswer) + | |
" / " + | |
new DecimalFormat("00").format(noAllQuestions)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light.NoActionBar"> | |
<item name="android:windowNoTitle">true</item> | |
<item name="android:windowActionBar">false</item> | |
<item name="android:windowFullscreen">true</item> | |
<item name="android:windowContentOverlay">@null</item> | |
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Defining the second activity for moving to. | |
Intent intent = new Intent(getApplicationContext(), SecondActivity.class); | |
// putting and extra into an intent so that on the other activity could be recieved. | |
intent.putExtra("editText", editText.getText().toString()); | |
// Starting the second activity | |
startActivity(intent); | |
// On the Second Activity: how te recieve the intent that opened this activity. | |
Intent intent=getIntent(); | |
// How to extract the extra that has been put in the intent before starting the activity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.ByteArrayInputStream; | |
import java.io.ByteArrayOutputStream; | |
import java.io.IOException; | |
import java.io.ObjectInputStream; | |
import java.io.ObjectOutputStream; | |
import java.io.Serializable; | |
public class ObjectSerializer { |