Android save state on orientation change

Add android:configChanges in the Manifest file <activity name= “.MainActivity” android:configChanges=”orientation|screenSize”/> By default, this does not work because changing the orientation causes the onCreate method to be called again and redraws the view. However, if this parameter is included, the framework will handle preserving the state of the screen or layout if the orientation is changed. … Read more

Android cannot pass intent extras though AlarmManager

UPDATE: Please see Vincent Hiribarren’s solution Old Answer… Haresh’s code is not the complete answer… I used a Bundle and I tried without Bundle but I got null’s either way when I attempting to obtain the strings from the extra’s !! The exact problem, in your code, is with the PendingIntent ! This is wrong … Read more

Android get the Intent when implementing RecognitionListener

The results should be in the bundle with the key SpeechRecognizer.RESULTS_RECOGNITION. @Override public void onResults(Bundle results) { if (results != null && results.containsKey(SpeechRecognizer.RESULTS_RECOGNITION)) { List<String> resultsList = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); // most likely result is resultsList.get(0) } else { // no results } } See the Android developer documentation for SpeechRecognizer explains it in detail. This method … Read more

What are the IPC mechanisms available in the Android OS?

IPC is inter-process communication. It describes the mechanisms used by different types of android components to communicate with one another. 1) Intents are messages which components can send and receive. It is a universal mechanism of passing data between processes. With help of the intents one can start services or activities, invoke broadcast receivers and … Read more

What is a “bundle” in an Android application

Bundles are generally used for passing data between various Android activities. It depends on you what type of values you want to pass, but bundles can hold all types of values and pass them to the new activity. You can use it like this: Intent intent = new… Intent(getApplicationContext(), SecondActivity.class); intent.putExtra(“myKey”, AnyValue); startActivity(intent); You can … Read more

Android: How to put an Enum in a Bundle?

Enums are Serializable so there is no issue. Given the following enum: enum YourEnum { TYPE1, TYPE2 } Bundle: // put bundle.putSerializable(“key”, YourEnum.TYPE1); // get YourEnum yourenum = (YourEnum) bundle.get(“key”); Intent: // put intent.putExtra(“key”, yourEnum); // get yourEnum = (YourEnum) intent.getSerializableExtra(“key”);