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="http://schemas.android.com/apk/res/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="com.google.android.gms.games.APP_ID"
            android:value="@string/app_id" />
        <meta-data android:name="com.google.android.gms.version"                   android:value="@integer/google_play_services_version"/>

        <activity            android:name="com.google.example.games.tanc.MainActivity"            android:label="@string/title_activity_main"            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

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.

Android


  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>
    



--androiddebugkey

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) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_basic_views);

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

        if(firstStart)
        { showStartDialog();}

    }

    public void showStartDialog()
    {
        android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(v.getContext());
        builder.setMessage("Check more apps!!!")
                .setCancelable(false)
                .setPositiveButton("OK GO", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/developer?id=Demilion") ) );
                    }
                })
                .setNegativeButton("NO", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
        builder.create()
                .show();

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





https://www.youtube.com/watch?v=2I1n6A6JJzw

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.
This-

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

BasicViewActivity-

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


https://www.dev2qa.com/passing-data-between-activities-android-tutorial/