Skip to content

Instantly share code, notes, and snippets.

@samsofa
samsofa / Helper Method - releaseMediaPlayer()
Created July 11, 2018 19:44 — forked from udacityandroid/Helper Method - releaseMediaPlayer()
Miwok app: Cleaning up MediaPlayer resources
/**
* Clean up the media player by releasing its resources.
*/
private void releaseMediaPlayer() {
// If the media player is not null, then it may be currently playing a sound.
if (mMediaPlayer != null) {
// Regardless of the current state of the media player, release its resources
// because we no longer need it.
mMediaPlayer.release();
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@samsofa
samsofa / MainActivity.java
Created December 12, 2018 09:22 — forked from anonymous/MainActivity.java
Activity Lifecycle exercise
package com.example.android.lifecycle;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
@samsofa
samsofa / strings.xml
Created April 6, 2019 11:59 — forked from udacityandroid/strings.xml
Android for Beginners : Spanish Localization Solution. This would be saved in the res/values-es/strings.xml file.
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Title for the application. [CHAR LIMIT=12] -->
<string name="app_name">Sólo Java</string>
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="name">Nombre</string>
<!-- Hint text display in the empty field for the user's name [CHAR LIMIT=20] -->
<string name="toppings">Ingredientes</string>
@samsofa
samsofa / MainActivity.java
Created July 20, 2020 07:53 — forked from jonathanbcsouza/MainActivity.java
SOLUTION FOR: DEPRECATED >> Uri downloadUrl = taskSnapshot.getDownloadUrl
// Udacity - Does not working
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
if (resultCode == RESULT_OK) {
Toast.makeText(getContext(), "Signed in!", Toast.LENGTH_SHORT).show();
} else if (resultCode == RESULT_CANCELED) {
Toast.makeText(getContext(), "Sign in canceled", Toast.LENGTH_SHORT).show();
getActivity().finish();
@samsofa
samsofa / Bean.java
Created August 5, 2020 20:01 — forked from DeepakRattan/Bean.java
Filtering ListView using Filterable interface
package com.almabay.filterlistdemo;
/**
* Created by deepakr on 3/29/2016.
*/
public class Bean {
String name, age;
public Bean(String name, String age) {
this.name = name;