my code stock.com

benoffi7

Splash solo una vez por dia
by benoffi7

Snippet options

Download: Download snippet as splash-solo-una-vez-por-dia.java.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

package com.coffeeandcookies.sinnombre;

import java.util.Calendar;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.VideoView;

public class lay_splash_video extends Activity 
{
	private VideoView video_view;
	SharedPreferences prefs;

	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) 
	 {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash_video);
		
		Levantar_XML();
		
		Calendar diaYHora= Calendar.getInstance();
		prefs = PreferenceManager.getDefaultSharedPreferences(this);
		
		//levantar los dias
		int diaSplash=prefs.getInt("dia", -1);
		int diaActual=diaYHora.get(Calendar.DAY_OF_MONTH);
		//pregunto
		if (diaActual==diaSplash)
		{
			Log.d("Mesas", "No muestro intro");
			Intent intento = new Intent(lay_splash_video.this, lay_main.class);
			startActivity(intento);
		}
		else
		{	
			Log.d("Mesas", "Muestro intro");
			//guardo el dia
			SharedPreferences.Editor editor = prefs.edit();
			editor.putInt("dia", diaActual);
			editor.commit();

			//hago lo que hay que hacer...
			
			String uri = "android.resource://" + getPackageName() + "/" + R.raw.splash;
			video_view.setVideoURI(Uri.parse(uri));
			video_view.start();
			
			video_view.setOnCompletionListener(new OnCompletionListener() {
				
				public void onCompletion(MediaPlayer mp) 
				{
					Intent intento = new Intent(lay_splash_video.this, lay_main.class);
					startActivity(intento);
					
				}
			});
		}
	}

	private void Levantar_XML() 
	{
		video_view=(VideoView)findViewById(R.id.video_view);
	}
	
	@Override
	protected void onResume() 
	{
		
		super.onResume();
		
	}
	
	@Override
	protected void onPause() 
	{
		finish();
		super.onPause();
	}
	
	
	
}

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.