viernes, 5 de junio de 2020

Audio android java

A continuación, se muestra un ejemplo de cómo reproducir un archivo de audio que está disponible como recurso local sin procesar (guardado en el directorio res/raw/ de tu app):
    MediaPlayer mediaPlayer = MediaPlayer.create(context, R.raw.sound_file_1);
    mediaPlayer.start(); // no need to call prepare(); create() does that for you

martes, 7 de enero de 2020

Error 12501 authenticating with google sign-in

<manifest xmlns:android=""    package="com.demilion.dontpoopyourpants">

    <application        android:supportsRtl="true"        android:allowBackup="true"        android:fullBackupContent="false"        android:icon="@drawable/ic_launcher"        android:label="@string/app_name"        android:theme="@style/AppTheme" >

        <meta-data android:name=""
            android:value="@string/app_id" />
        <meta-data android:name=""                   android:value="@integer/google_play_services_version"/>

        <activity            android:name=""            android:label="@string/title_activity_main"            android:screenOrientation="portrait" >
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />

Keystore file does not exist

The debug keystore file isn't in your application's directory, it's in your .android directory. If you're using Windows, it's probably in C:\Users\yourname\.android (where instead of "yourname" use your own User directory).
Once you know where it is, you can run the keytool like this:
    keytool -list -v -keystore "C:\Users\yourname\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

Specify client ID settings

Next, specify your client ID settings by following the instructions specific to your platform.


  1. Choose Installed application as your Application type and select Android as the installed application type (these should be your only options).
  2. In the Package name field, enter your Android application's package name.
  3. Open a terminal and run the Keytool utility to get the SHA1 fingerprint of the certificate. You should get both the release and debug certificate fingerprints.
    To get the release certificate fingerprint:
    keytool -list -keystore <path-to-production-keystore>
    To get the debug certificate fingerprint:
    keytool -list -keystore <path-to-debug-keystore>


4. The keytool prompts you to enter a password for the keystore. The default password for the debug keystore is android. The keytool then prints the fingerprint to the terminal.

5. Paste the SHA1 fingerprint into the Signing certificate fingerprint (SHA1) field.

6. Click the Create client button, then follow the steps in the Gather credentials for authentication and authorization section below.

see on:

lunes, 6 de enero de 2020

Do Something on First App Start Only - Android Studio Tutorial

Do Something on First App Start Only

public class MainMenu extends Activity {

    @Override    protected void onCreate(Bundle savedInstanceState) {


        SharedPreferences prefs  = getSharedPreferences("prefs", MODE_PRIVATE);
        boolean firstStart = prefs.getBoolean("firstStart", true);

        { showStartDialog();}


    public void showStartDialog()
    { builder = new;
        builder.setMessage("Check more apps!!!")
                .setPositiveButton("OK GO", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("") ) );
                .setNegativeButton("NO", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {

        SharedPreferences prefs = getSharedPreferences("prefs", MODE_PRIVATE);
        SharedPreferences.Editor editor = prefs.edit();
        editor.putBoolean("fistStart", false);

miércoles, 1 de enero de 2020

Passing Data To Other Activity Using Intent.

  1. Create a New Explicit or Implicit Intent object in source activity.
  2. Call intent.putExtra(String key, Object data) method to save data in it.
  3. Call startActivity(intent) method in source activity to pass the intent to android os.
  4. Call getIntent() method in target activity.
  5. Use intent.getStringExtra(String key) to get the transferred data.

Intent intent = new Intent(this, BasicViewsActivity.class);
intent.putExtra("amountTime", String.valueOf(amountTime));


Intent intent = getIntent();
String amountTime =   intent.getStringExtra("amountTime");

jueves, 26 de diciembre de 2019

Send data from javascript to Native Android app.

Hello, here is sample code about how to send data from HTML/Javascript to native Android app using webview.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""

        android:layout_height="fill_parent" />


<!DOCTYPE html>
    <meta charset="UTF-8">
        content="width=device-width; user-scalable=0;" />
    <title>HTML Android</title>
    <h1>HTML Android</h1>
        value="Button 1"
        onClick="sendDataToAndroid('Button 1 is click')" />

        value="Button 2"
        onClick="sendDataToAndroid('Button 2 is click')" />

    function sendDataToAndroid(toast) {
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import android.widget.Toast;

@SuppressLint({"NewApi", "SetJavaScriptEnabled"})
public class WebViewActivity extends Activity {

    WebView mWebViewDemo;

    protected void onCreate(Bundle savedInstanceState) {
        mWebViewDemo = (WebView) findViewById(;
        ButtonClickJavascriptInterface myJavaScriptInterface = new ButtonClickJavascriptInterface(WebViewActivity.this);
        mWebViewDemo.addJavascriptInterface(myJavaScriptInterface, "MyFunction");


    public class ButtonClickJavascriptInterface {
        Context mContext;
        ButtonClickJavascriptInterface(Context c) {
            mContext = c;

        public void onButtonClick(String toast) {
            Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();