Documentos de Académico
Documentos de Profesional
Documentos de Cultura
TAREA:
MATERIA:
ELECTIVA IV
DOCENTE:
Msc. SANTOS DIAZ LILIA BEATRIZ
ESTUDIANTE:
COELLO MOSQUERA SONIA BEATRIZ
PARALELO:
ISI-S-MA-8-6
PERIODO
2020 -2021 CI
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/btnIniciar"
android:layout_width="150dp"
android:layout_height="45dp"
android:onClick="onClickListenerBtnIniciar"
android:text="PLAY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.605" />
<Button
android:id="@+id/btnFinalizar"
android:layout_width="150dp"
android:layout_height="48dp"
android:onClick="onClickListenerBtnFinalizar"
android:text="STOP"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.709" />
<TextView
android:id="@+id/textView"
android:layout_width="258dp"
android:layout_height="34dp"
android:fontFamily="sans-serif-black"
android:text="Reproductor de Música"
android:textColorLink="@color/colorAccent"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.503"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.499" />
<ImageView
android:id="@+id/imageView"
android:layout_width="165dp"
android:layout_height="170dp"
android:layout_marginTop="28dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.074
app:srcCompat="@mipmap/logo_ug" />
</LinearLayout >
}
}
btnIniciar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onClickListenerBtnIniciar(view);
}
});
btnFinalizar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
onClickListenerBtnFinalizar(view);
}
});
}
package com.example.servicio;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.content.ContentValues;
import android.content.Context;
import android.media.MediaPlayer;
import android.widget.Button;
import android.widget.Toast;
@Override
public void onCreate(){
btnIniciar = (Button) btnIniciar.findViewById(R.id.btnIniciar);
btnFinalizar = (Button) btnFinalizar.findViewById(R.id.btnFinalizar);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId){
vectormp[0] =MediaPlayer.create(thisContext, R.raw.cancion1);
vectormp[1] =MediaPlayer.create(thisContext, R.raw.cancion2);
vectormp[2] =MediaPlayer.create(thisContext, R.raw.cancion3);
if(vectormp[posicion].isPlaying())
{
vectormp[posicion].pause();
Toast.makeText(thisContext,"Pausa", Toast.LENGTH_SHORT).show();
}
else
{
vectormp[posicion].start();
Toast.makeText(thisContext,"Play", Toast.LENGTH_SHORT).show();
}
return START_STICKY;
}
@Override
public void onDestroy() {
super.onDestroy();
mediaPlayer.stop();
mediaPlayer.release();
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
}
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity android:name=".MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />